Python BeautifulSoup extract html table cells that contains images and text

Piet van Oostrum piet-l at vanoostrum.org
Sat Jul 29 10:32:28 EDT 2017


Umar Yusuf <bintacomputers at gmail.com> writes:
> Hi all,
>> I need help extracting the table from this url...?
>> from bs4 import BeautifulSoup
> url = "https://www.marinetraffic.com/en/ais/index/ports/all/per_page:50"
>> headers = {'User-agent': 'Mozilla/5.0'}
> raw_html = requests.get(url, headers=headers)
>> raw_data = raw_html.text
> soup_data = BeautifulSoup(raw_data, "lxml")
>> td = soup_data.findAll('tr')[1:]
>> country = []
>> for data in td:
> col = data.find_all('td')
> country.append(col)

So what data do you want to extract?
-- 
Piet van Oostrum <piet-l at vanoostrum.org>
WWW: http://piet.vanoostrum.org/
PGP key: [8DAE142BE17999C4]


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /