码迷,mamicode.com
首页 > 编程语言 > 详细

python bs4 + requests4 简单爬虫

时间:2018-08-11 15:35:25      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:app   logs   odi   from   htm   www.   html   bs4   yar   

参考链接:

bs4和requests的使用:https://www.cnblogs.com/baojinjin/p/6819389.html

安装pip:https://blog.csdn.net/zwr_20121141/article/details/80293806

# python 3.x 开始自带了pip,如果没有请自信百度安装。
# pip install beautifulsoup4 requests
from bs4 import BeautifulSoup
import requests

res = requests.get(https://etherscan.io/token/tokenholderchart/0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0?range=10)
res.encoding=gbk
soup = BeautifulSoup(res.text,html.parser)
table = soup.select(#ContentPlaceHolder1_resultrows table tr)
myarr = []
for tr in table:
    td = tr.select(td)
    if len(td) > 0:
        Rank = td[0].text;
        Address = td[1].text;
        Quantity = td[2].text;
        Percentage = td[3].text;
        myarr.append({"Rank": Rank, "Address": Address, "Quantity": Quantity, "Percentage": Percentage})
print(myarr)

 

python bs4 + requests4 简单爬虫

标签:app   logs   odi   from   htm   www.   html   bs4   yar   

原文地址:https://www.cnblogs.com/CyLee/p/9459638.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!