ThatOnePythonNoob ThatOnePythonNoob - 1 year ago 169
Python Question

How to search a search field on a webpage?

How can I open a webpage, for example:

... And search for an item using the search field on the page?

i.e. "Search for a player..."

Answer Source

You don't need to scrape the webpage, it has a direct search API

import requests
s = "Ronaldo"
r = requests.get("{}".format(s))


[{u'club_image': u'/content/fifa16/img/clubs/243.png',
  u'full_name': u'Cristiano Ronaldo',
  u'id': u'38387',
  u'image': u'/content/fifa16/img/players/20801.png',
  u'nation_image': u'/content/fifa16/img/nation/38.png',
  u'position': u'LW',
  u'rare': u'1',
  u'rare_type': u'11',
  u'rating': u'99'},


from bs4 import BeautifulSoup
import requests

r = requests.get("")
soup = BeautifulSoup(r.text, "html.parser")
pslbin = soup.findAll("span", {'id': "pslbin"})[0].text.strip()
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download