(Jun-27-2017, 06:34 PM)datafix Wrote: Running on Cloud9- that shouldn't make a difference- do you think?
I use
Cloud9 sometime myself.
Cloud9 has Python 2 and 3 installed,you have to
pip3 install module
,
and run code with
python3 myscript.py
Here a run at Cloud9.
# install modules
snippsat:~/workspace/bs4_test $ sudo pip3 install beautifulsoup4 requests lxml
Downloading/unpacking beautifulsoup4
Downloading beautifulsoup4-4.6.0-py3-none-any.whl (86kB): 86kB downloaded
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3/dist-packages
Downloading/unpacking lxml
Downloading lxml-3.8.0.tar.gz (3.8MB): 3.8MB downloaded
Running setup.py (path:/tmp/pip_build_root/lxml/setup.py) egg_info for package lxml
Building lxml version 3.8.0.
Building without Cython.
Using build configuration of libxslt 1.1.28
Successfully installed beautifulsoup4 lxml
Cleaning up...
# After install can run a interactive test
snippsat:~/workspace/bs4_test $ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> from bs4 import BeautifulSoup
>>>
>>> url = 'https://www.python.org/'
>>> url_get = requests.get(url)
>>> soup = BeautifulSoup(url_get.content, 'lxml')
>>> print(soup.select('head > title')[0].text)
Welcome to Python.org
>>>