1

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.

halfer
20.2k20 gold badges111 silver badges208 bronze badges
asked Feb 6, 2017 at 19:12

1 Answer 1

1
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.

answered Feb 6, 2017 at 19:19
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer and precisions !

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.