V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
yellowtail
V2EX  ›  问与答

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

  •  
  •   yellowtail · 2019-10-10 15:33:02 +08:00 · 1703 次点击
    这是一个创建于 1631 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    要开始学些什么。。

    13 条回复    2019-10-10 17:03:53 +08:00
    soho176
        1
    soho176  
       2019-10-10 16:02:03 +08:00
    python 正则,再或者简单的办法 火车头 直接抓取
    di1012
        2
    di1012  
       2019-10-10 16:03:46 +08:00
    正则匹配,xpath
    biu7
        3
    biu7  
       2019-10-10 16:11:26 +08:00


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

    driver.find_element_by_xpath()
    lspvic
        9
    lspvic  
       2019-10-10 16:31:30 +08:00 via Android   ❤️ 1
    爬虫可以看看有没有对应的移动版网页,网页简洁许多,好解析,速度快,效率高,甚至有些直接有 api 可用
    yellowtail
        10
    yellowtail  
    OP
       2019-10-10 16:37:52 +08:00
    @None123 全部阅读数应该是自己一个一个的加。。这样拿到的是一个数组吗
    None123
        11
    None123  
       2019-10-10 16:40:01 +08:00
    @yellowtail 什么意思?
    houzhimeng
        12
    houzhimeng  
       2019-10-10 16:54:38 +08:00   ❤️ 1
    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
        13
    yellowtail  
    OP
       2019-10-10 17:03:53 +08:00
    @houzhimeng 感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5493 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 09:06 · PVG 17:06 · LAX 02:06 · JFK 05:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.