Reputation: 55
I'm trying to create a scraping script in Python 2.7.
The request is ok, but I have a hard time trying to parse this table with Beautiful soup. I've tried a lot, and searched a lot on the forum, but nothing works for me, my first time doing this.
Here is the code :
import requests, os
from bs4 import BeautifulSoup
url='http://fse.vdkruijssen.eu/ferrylist.php' params={'selectplane':'Cessna 208 Caravan','submit':''}
response=requests.post(url, data=params)
soup = BeautifulSoup(response.text, "html5lib")
table=soup.find('table')
print table
But this is not returning any table. I'm trying to retrieve the first and the last column at least.
Upvotes: 1
Views: 71
Reputation: 12178
soup = BeautifulSoup(response.text, "lxml")
change the parser to lxml
Beautiful Soup supports the HTML parser included in Python’s standard library, but it also supports a number of third-party Python parsers. One is the lxml parser. Depending on your setup, you might install lxml with one of these commands:
$ apt-get install python-lxml
$ easy_install lxml
$ pip install lxml
By default, BS4 use lxml
parser.
Upvotes: 1