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.

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer and precisions !

Your Answer

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.