谷歌搜索“龙球壁纸”上的python web抓取

问题描述 投票:0回答:1
from urllib.request import urlopen
from bs4 import BeautifulSoup
import urllib
import random
from string import ascii_lowercase

def makesoup(url):
    thepage=urlopen(url)
    soupdata=BeautifulSoup(thepage, 'html.parser')
    return soupdata

soup=makesoup("https://www.google.com/search?q=dragon+ball+super+wallpaper&source=lnms&tbm=isch&sa=X&ved=0ahUKEwihzY6OvpfdAhVrJcAKHRi2D8cQ_AUICigB&biw=1366&bih=662")
print(soup.text)

我在urlopen()上收到错误。我真的需要一些帮助。

python web-scraping
1个回答
0
投票

谷歌不喜欢通过脚本或框架请求。如果你想从谷歌搜索另一个应用程序,你应该尝试使用谷歌搜索API。

https://developers.google.com/custom-search/json-api/v1/overview

是的,它每天仅限100个请求,但它是唯一合法的选择。

© www.soinside.com 2019 - 2024. All rights reserved.