【问题标题】:Ebay Scraper code most of the time doesn't workEbay Scraper 代码大部分时间不起作用
【发布时间】:2022-01-21 02:55:48
【问题描述】:

我目前正在学习通过以下链接创建 Ebay Scraper 的教程:

https://www.youtube.com/watch?v=csj1RoLTMIA&t=290s

我正在编写代码,突然注意到我下面的代码有时只能工作:

import requests
from bs4 import BeautifulSoup
import pandas as pd

url = 'https://www.ebay.co.uk/sch/i.html?_from=R40&_nkw=gaggia+classic&_sacat=0&LH_TitleDesc=0&LH_Auction=1&LH_Sold=1&rt=nc'

def get_data(url):
    r = requests.get(url)
    soup = BeautifulSoup(r.text, 'html.parser')
    return soup

def parse(soup):
    results = soup.find_all('div', {'class': 's-item__info clearfix'})
    print(len(results))
    return

soup = get_data(url)
parse(soup)

大多数时候代码会输出 0,但有时会输出 51(这是正确答案)。有人知道如何让它工作吗?

【问题讨论】:

    标签: python web-scraping


    【解决方案1】:

    该视频已有一年多的历史了,eBay 等大公司正在采取措施防止数据挖掘者和网络抓取工具之类的事情发生。您可能会受到速率限制(发送请求太快并标记反机器人系统)。

    【讨论】:

    • 谢谢。在这种情况下,是否有可能绕过此问题的教程?
    【解决方案2】:

    这篇来自 zyte(原 ScrapingHub)的文章可能会对您有所帮助 - How to scrape the web without getting blocked

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 2019-04-23
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      相关资源
      最近更新 更多