爬虫小白求教如何得到东方财富股吧第一页的全部阅读数?

2019-10-10 15:33:02 +08:00
 yellowtail

http://guba.eastmoney.com/list,600519.html

要开始学些什么。。

1733 次点击
所在节点    问与答
13 条回复
soho176
2019-10-10 16:02:03 +08:00
python 正则,再或者简单的办法 火车头 直接抓取
di1012
2019-10-10 16:03:46 +08:00
正则匹配,xpath
biu7
2019-10-10 16:11:26 +08:00


xpath 正则
None123
2019-10-10 16:12:26 +08:00
requests 获取网页
xpath / re 解析
silencefent
2019-10-10 16:20:26 +08:00
//div[@id='articlelistnew']//div/span[@class="l1 a1"]
yellowtail
2019-10-10 16:23:51 +08:00
还是不太明白,,用过 selenium,通过 findbyname 定位到“一个”标签,然后输入用户民密码,登录,refresh。。给论坛刷积分 但是这种的没看出来怎么定位到“一个”。。。各位大佬能不能简单写个栗子 主要想学会怎么看这个问题
yellowtail
2019-10-10 16:24:45 +08:00
@silencefent 这可以拿出来第一页的全部目标元素吗...
None123
2019-10-10 16:27:56 +08:00
@yellowtail

driver.find_element_by_xpath()
lspvic
2019-10-10 16:31:30 +08:00
爬虫可以看看有没有对应的移动版网页,网页简洁许多,好解析,速度快,效率高,甚至有些直接有 api 可用
yellowtail
2019-10-10 16:37:52 +08:00
@None123 全部阅读数应该是自己一个一个的加。。这样拿到的是一个数组吗
None123
2019-10-10 16:40:01 +08:00
@yellowtail 什么意思?
houzhimeng
2019-10-10 16:54:38 +08:00
from bs4 import BeautifulSoup
import requests

html = "http://guba.eastmoney.com/list,600519.html"
r = requests.get(html).content
soup = BeautifulSoup(r,"lxml")
yuedu = soup.find_all('span',{'class':'l1 a1'})
for i in yuedu:
print(i.get_text())
yellowtail
2019-10-10 17:03:53 +08:00
@houzhimeng 感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/607910

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX