【问题标题】:Web Crawling : Difficulty in finding required link using inspect element网络抓取:使用检查元素难以找到所需的链接
【发布时间】:2015-10-13 14:48:41
【问题描述】:

我是网络爬虫的初学者,我正在使用 BeautifulSoup。 我试图抓取页面“https://www.codechef.com/rankings/ACMAMR15?filterBy=&order=asc&page=2&sortBy=rank

(访问链接了解查询)

我想要所有链接,例如:“acm15am1235”。 我尝试使用 soup.findAll('a') ,但无法识别要在 soup.findAll 中传递什么类型的标签以获取所需的链接。

请指明捕获所需链接的方法。

【问题讨论】:

    标签: python-2.7 web-crawler


    【解决方案1】:

    首先你必须得到所有包含链接的div

    usernames = soup.find_all("div", class_="user-name")
    

    下一个:

    for username in usernames:
        print "link is :" + str(username.a['href'])
    

    【讨论】:

      猜你喜欢
      • 2021-06-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-13
      • 2019-04-24
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多