谷歌搜索“龙珠壁纸”上的python网络抓取

时间:2018-08-31 14:30:09

标签: python web-scraping

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()上收到错误消息。我真的需要一些帮助。

1 个答案:

答案 0 :(得分:0)

不希望通过脚本或框架请求Google。如果要从其他应用程序通过Google搜索,则应尝试使用Google搜索API。

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

是的,每天最多只能请求100个请求,但这是唯一的合法选择。