python - 如何读取关键字列表并将每个关键字放在网址末尾

标签 python steam

好吧,我正在尝试制作一个程序,告诉用户可以从他们提交的列表中获取哪些 Steam 自定义 URL,但我最近才开始使用 python,所以我只知道一点,我有一个工作程序,允许用户输入单个关键字,它会告诉他们该 URL 是否可用,但我希望他们能够输入关键字列表,它会检查每个关键字并仅打印可用的关键字关于如何执行此操作的任何想法

到目前为止我的代码

#Steam Custom Url Checker
#Started 21/09/2017
#Finished


import requests

keyword = (input("\n Please enter a keyword "))

url = ("http://steamcommunity.com/id/")

r = requests.get(url + keyword)


if 'The specified profile could not be found.' in r.text:
    print("\n Avaiable Custom Urls")
print("\n", url + keyword)
else :
    print('\nSorry that one is taken')

最佳答案

url = ("http://steamcommunity.com/id/")

#list having the keywords (made by splitting input with space as its delimiter) 
keyword = input().split()

#go through the keywords
for key in keywords :

   #everything else is same logic
   r = requests.get(url + key)

   print("URL :", url+key)
   if 'The specified profile could not be found.' in r.text:
        print("This is available")
   else :
        print('\nSorry that one is taken')

这应该遍历您的关键字列表,其他所有内容都是相同的。

关于python - 如何读取关键字列表并将每个关键字放在网址末尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46371278/

相关文章:

python - 在循环 python/pandas 中保存时不同的文件名

python - 使用 urllib2 缺少源页面信息

javascript - 关闭 CS :GO Dedicated Server via Node. js child_process

php - 返回错误 mysqli_query() expects parameter 1 to be mysqli, null given for steam login

python - 使用 Dask 从 postgresql 导入数据

python - 如何循环遍历 zip() 函数的一个元素两次 - Python

python - 网状网络 Xbee、Python

python - 管理包: PyCharm vs conda vs pip

java - 今天我们真的需要在 close() 之前调用 flush() 吗?

javascript - 如何在nodejs中输出 'i'