好吧,所以我有一个问题,我查了它,但并不知道究竟要查找什么,并不断看到问题,这与我的无关。因此,我的问题是即时通讯输入在pythonPython:检查输入的第一个字符
flashSite = raw_input('[?] Please Provide a Web Url : ')
后它需要我希望它检查HTTP输入://字符包括在输入的开始,如果他们是那么不添加它们再次,如果他们arent再加入他们在为用户,非常感谢帮助。另外即时通讯新的Stackoverflow,所以我会遇到问题,如把代码放在评论和这样的小东西:(
编辑: 所以从其他的答案和评论我来到了这个
def ScrapeFlashFiles():
flashSite = raw_input('Please Provide a web URL : ')
if flashSite.lower().startswith(flashSite, beg=0, end=7('http://')):
return flashSite
elif flashSite.lower().startswith(flashSite, beg=0, end=4('www.')):
flashSite = 'http://' + flashSite
print ' Sending requests... '
flashReq = requests.get(flashSite)
print ' Scraping content '
flashTree = html.fromstring(flashReq.content)
print 'Searching for keyword \'.swf\' '
for line in flashReq.content.split('\n'):
if '.swf' in line:
print line
print 'Flash Scrape Complete..'
我在这里干什么什么了吗?
注意我是初学者..即时得到一个错误,现在谈论一个int ..
源的地方,我正在读关于startswith方法 https://www.tutorialspoint.com/python/string_startswith.htm
有一个看看'startswith'方法字符串 –
因此,可能使用beg和end参数使用startswith方法创建if语句? – Xploit
太简单了。当你得到了输入,检查前7个字符:if slashSite [0:7] ==“http://”... –