BeautifulSoup-从特定的CSS路径获取内容

时间:2018-10-19 08:25:20

标签: python web-scraping beautifulsoup

我不知道如何获取以下CSS路径下的html内容: html body div table tbody tr td.outline div#content_outer div#content_inner table.content_table tbody tr td table.content_table tbody tr td.body_outer table

下面的代码不起作用:

import requests, time, re, pymysql, datetime
from bs4 import BeautifulSoup
from datetime import timedelta

try:
    page_address = "http://<my_page>"
    page = requests.get(page_address)

except requests.ConnectionError:
    print("Connection Error")


soup = BeautifulSoup(page.content, 'html.parser')

content = soup.select('html body div table tbody tr td.outline div#content_outer div#content_inner table.content_table tbody tr td table.content_table tbody tr td.body_outer table')

print(content)

可以帮忙吗?

0 个答案:

没有答案