yellowtail
V2EX  ›  问与答

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

  •  
  •   yellowtail · Oct 10, 2019 · 2650 views
    This topic created in 2409 days ago, the information mentioned may be changed or developed.

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

    要开始学些什么。。

    13 replies    2019-10-10 17:03:53 +08:00
    soho176
        1
    soho176  
       Oct 10, 2019
    python 正则,再或者简单的办法 火车头 直接抓取
    di1012
        2
    di1012  
       Oct 10, 2019
    正则匹配,xpath
    biu7
        3
    biu7  
       Oct 10, 2019


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

    driver.find_element_by_xpath()
    lspvic
        9
    lspvic  
       Oct 10, 2019 via Android   ❤️ 1
    爬虫可以看看有没有对应的移动版网页,网页简洁许多,好解析,速度快,效率高,甚至有些直接有 api 可用
    yellowtail
        10
    yellowtail  
    OP
       Oct 10, 2019
    @None123 全部阅读数应该是自己一个一个的加。。这样拿到的是一个数组吗
    None123
        11
    None123  
       Oct 10, 2019
    @yellowtail 什么意思?
    houzhimeng
        12
    houzhimeng  
       Oct 10, 2019   ❤️ 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
       Oct 10, 2019
    @houzhimeng 感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2969 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 04:57 · PVG 12:57 · LAX 21:57 · JFK 00:57
    ♥ Do have faith in what you're doing.