I have a similar question to this (Entering Value into Search Bar and Downloading Output from Webpage) where I am trying to search this webpage (https://megascatterbomb.com/mcd), and automatically entering SteamID's like this [U:1:891772657] from a list. Then I simply want to see if that ID has been flagged as cheating (it appears below the searcch box). The simplest way I can see to do that is to see if a names is displayed and then get what colour the text is (Red #ff3300, Yellow #ffff00, Green #33ff00 or White #ffffff).
I have spent quite a few hours trying to understand the link I shared above and how it works with the website it relates to and then converting it to work in my scenario.
But I can't quite get across it with one part being that my instance doesn't insert text into the HTML to perform the search, so I can't work out how to make the query.
There's a couple of other bits I'm struggling with but that's the main part for now.
I am familiar with BeautifulSoup and know it's great through reputation, but my understanding of how it works is poor.
This is what I have so far, but if feels very wrong and added as it was suggested below.
import requestsfrom bs4 import BeautifulSoupimport csvfrom string import ascii_lowercaseimport codecsimport os.pathimport timedef get_post_data(html_soup, query): search_input = html_soup.find('input', {'id': 'searchinput'}) search_results = html_soup.find('div', ('id' : 'searchresults'}) return {'placeholder': query,'color': '', }player_steam_ids = ['[U:1:891772657]']url = 'https://megascatterbomb.com/mcd'html = requests.get(url).contentfor each in player_steam_ids: payload = get_post_data(BeautifulSoup(html, 'lxml'), each) r = requests.post(url, data=payload).content outfile = "raw/" + each +".html" with open(outfile, "w") as code: code.write(r) time.sleep(2)
Any help would be greatly appreciated.
Thanks,Markus