2017-09-22 9 views
1

[OK]をクリックすると、送信するリストから利用可能なスチームカスタムURLをユーザーに知らせるプログラムを作成しようとしていますが、私は少しだけ知っているので、私はユーザーに単一のキーワードを入力させる作業プログラムを持っており、URLが利用可能かどうかを示しますが、キーワードのリストを入力できるようにして、彼らとプリントのみ利用可能なもの、私はこのキーワードのリストを読み込んでURLの最後に1つずつ入れる方法

私のコードを実行することができる方法上の任意のアイデアこれまで

#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') 

答えて

2
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') 

これはキーワードのリストを繰り返す必要があり、それ以外はすべて同じです。

0
import requests 

keywords = (raw_input("\n Please enter a list keyword ")) 

available_keywords =[] 
for keyword in keywords.split(): 
    url = ("http://steamcommunity.com/id/") 
    r = requests.get(url + keyword) 

    if 'The specified profile could not be found.' in r.text: 
     available_keywords.append(url+keyword) 

if len(available_keywords) >0: 
    print("List of available_keywords : ") 
    for url in available_keywords: 
     print (url) 
else: 
    print ("Sorry no url is abailable") 
0
import requests 

keyword = (input("\n Please enter the keywords ")) 
keywords = keyword.split(" ") 
url = ("http://steamcommunity.com/id/") 
avai = list() 

for key in keywords: 
    r = requests.get(url + key) 
    if 'The specified profile could not be found.' in r.text: 
     avai.append(key) 

if len(avai)>0: 
    print("\n Avaiable Custom Urls") 
    for k in avai: 
     print("\n", url + k) 
else : 
    print('\nSorry no url available') 
関連する問題