我试着让我的代码在这个网站的页面中递增,但我似乎无法让它循环递增,而是做第一个页面,然后放弃。我做错什么了吗?你知道吗
if(pageExist is not None):
if(countitup != pageNum):
countitup = countitup + 1
driver.get('http://800notes.com/Phone.aspx/%s/%s' % (tele800,countitup))
delay = 4
scamNum = soup.find_all(text=re.compile(r"Scam"))
spamNum = soup.find_all(text=re.compile(r"Call type: Telemarketer"))
debtNum = soup.find_all(text=re.compile(r"Call type: Debt Collector"))
hospitalNum = soup.find_all(text=re.compile(r"Hospital"))
scamCount = len(scamNum) + scamCount
spamCount = len(spamNum) + spamCount
debtCount = len(debtNum) + debtCount
hospitalCount = len(hospitalNum) + hospitalCount
block = soup.find(text=re.compile(r"OctoNet HTTP filter"))
extrablock = soup.find(text=re.compile(r"returning an unknown error"))
type(block) is str
type(extrablock) is str
if(block is not None or extrablock is not None):
print("\n Damn. Gimme an hour to fix this.")
time.sleep(2000)
回购:https://github.com/GarnetSunset/Haircuttery/tree/Experimental
pageExist is not None
这似乎就是问题所在。 因为它检查页面是否为无,而且很可能永远不会为无。没有官方的方法来检查HTTP响应,但是我们可以使用类似的方法。你知道吗或者
我相信有其他方法可以做到这一点,但这是其中之一,所以这是这里唯一的问题。一旦修复了第一个if,就可以增加或保留代码的其余部分。你知道吗
我可能在我的代码中犯了一些错误(语法),因为我没有测试它,但逻辑适用),太棒了!
也代替了
Python的方法是 isinstace
至于
time.sleep
您可以使用WebDriverWait有两种可用的方法,隐式和显式等待,请看here。你知道吗相关问题 更多 >
编程相关推荐