Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import bs4
- def main():
- search = input("What is the username that you want to search for?")
- html, url = get_html_from_web(search)
- username, account_value = get_info_from_html(html)
- if username == None and account_value == None:
- print('There is no account named {}'.format(search))
- else:
- print("{}'s account is worth {}! Info collected from {}".format(
- username.strip(),
- account_value,
- url
- ))
- def get_html_from_web(search):
- url = 'https://steamdb.info/calculator/?player={}&cc=ca'.format(search)
- response = requests.get(url)
- return response.text, url
- def get_info_from_html(html):
- soup = bs4.BeautifulSoup(html, 'html.parser')
- # usernameCss = 'h1.header-title a'
- # accountValueCss = 'span.number-price-lowest'
- try:
- username = soup.find(class_='header-title').get_text()
- except AttributeError:
- return None, None
- try:
- account_value = soup.find(class_='number-price-lowest').get_text()
- except AttributeError:
- return None, None
- return username, account_value
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment