感谢所有帮助。 :)
import urllib.request
ans = True
while ans:
print("""
- Menu Selection -
1. Automatic
2. Manual
3. Add
4. Exit
""")
ans = input('Select Option : ')
if ans =="1":
with urllib.request.urlopen('http://www.mywebsite.net/something.txt') as response:
html = response.read()
f = open('proxylist.txt','a')
f.write(str(html))
f.close()
print('Data saved.')
ans = True
if ans =="2":
input('Enter link : ')
link = input()
try:
with urllib.request.urlopen(link) as response:
html1 = response.read()
f = open('proxylist.txt','a+')
f.write(str(html1))
f.close()
print('Data saved.')
ans = True
except:
print('User Input Error')
ans = True
答案 0 :(得分:1)
您尝试输入两次数据并忽略第一个结果:
input('Enter link : ')
link = input()
将其更改为:
link = input('Enter link : ')