一。问题:想要取网页里的表格数据,
比如网址:
https://data.eastmoney.com/gpzy/detail/000001.html
需要取到图片里的表格数据。
二.问题相关代码
import requests
from bs4 import BeautifulSoup
import pandas as pd
import os
import time
url='https://data.eastmoney.com/gpzy/stock/000001.html'
response=requests.get(url)
time.sleep(3)
response.encoding = 'utf-8'
response.encoding=response.apparent_encoding
soup=BeautifulSoup(response.text,features="html.parser") # 爬取不到数据。
print (soup)
三。程序没有报错,但 print (soup) 里就是取不到该表格数据,只有表格信息。
你需要使用 .find()
和 .text
依次解析你的表格 HTML 数据才能获取到数据,需要自己写。
爬虫相关问题欢迎问我鸭~