为什么有些搜索栏不能处理Python请求?

时间:2017-05-03 21:56:01

标签: python beautifulsoup python-requests

无论出于何种原因,我似乎无法在搜索栏中实际搜索此请求。此网站上有2个搜索栏,一个位于页眉的右上角,另一个位于主页面上。也许这与此有关?有什么想法吗?

这是我的代码:

from bs4 import BeautifulSoup as soup
import requests
beername = "guinness"
url = 'https://untappd.com/search?'
search_params = {'query': beername}
r = requests.get(url, params=search_params)
r = requests.post(url, params=search_params) # <-doesn't work either
s = soup(r.content, 'html.parser')
containers = s.findAll('div', {'class': "beer-item "})
print(len(containers)) # this returns 0 right now

1 个答案:

答案 0 :(得分:0)

查询代码名称为"q",而非"query"

负责任地享受!