与 Steam 相关的 Python 程序
Steam-related Python program
我正致力于在 Python 中制作一个程序,该程序采用用户输入的字典单词列表(用逗号或单独的行分隔),然后将每个单词添加到 URL (http://steamcommunity.com/id/) it then checks each one of the URLs and only prints the ones with "The specified profile could not be found." text on the web page (example http://prntscr.com/gjdzuf).
我知道这很可能不是很困难,但我最近才开始学习 Python,我只是在寻找最简单的方法来完成我想要实现的目标。
您正在查找 requests
模块。对于像检查文本是否在页面中这样简单的事情,这可以做到:
import requests
r = requests.get('http://steamcommunity.com/id/')
if 'The specified profile could not be found.' in r.text:
print('Invalid profile!')
else:
print('Found a profile.')
对于更复杂的处理,需要BeautifulSoup4
等解析库。
这种做法被称为 "web scraping",并且 Python 有很好的工具。
我正致力于在 Python 中制作一个程序,该程序采用用户输入的字典单词列表(用逗号或单独的行分隔),然后将每个单词添加到 URL (http://steamcommunity.com/id/) it then checks each one of the URLs and only prints the ones with "The specified profile could not be found." text on the web page (example http://prntscr.com/gjdzuf).
我知道这很可能不是很困难,但我最近才开始学习 Python,我只是在寻找最简单的方法来完成我想要实现的目标。
您正在查找 requests
模块。对于像检查文本是否在页面中这样简单的事情,这可以做到:
import requests
r = requests.get('http://steamcommunity.com/id/')
if 'The specified profile could not be found.' in r.text:
print('Invalid profile!')
else:
print('Found a profile.')
对于更复杂的处理,需要BeautifulSoup4
等解析库。
这种做法被称为 "web scraping",并且 Python 有很好的工具。