python爬虫之表格的提取

python爬虫之表格的提取,第1张

首先要下载第三方库

pip install pandas
pip install requests
pip install urllib3

 爬虫之表格的提取源代码

import pandas as pd
import requests
import urllib3
urllib3.disable_warnings()
#网址
url = "http://www.stats.gov.cn/ztjc/zdtjgz/zgrkpc/dqcrkpc/ggl/202105/t20210519_1817699.html"
response = requests.get(url, verify=False)
response.encoding = response.apparent_encoding
html = response.text
tb = pd.read_html(html, header=0)[0]
#最后生成的csv文件
tb.to_csv("biaoge.csv")

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/916130.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-16
下一篇2022-05-16

发表评论

登录后才能评论

评论列表(0条)

    保存