问题描述
我遇到以下问题:我尝试抓取域名调查网站(https://namecensus.com/male_names.htm) 使用以下代码:
for counter in range(0,len(links_male)):
print("Sleeping for 2 Seconds")
time.sleep(2)
print(url)
html_page=rq.get(url)
bs_instance_male=BeautifulSoup(html_page.text,"html.parser")
print(bs_instance.h1)
table_entries=bs_instance.select(".datatable > table >tr >td")
for entry in table_entries:
male_firstname_data.append(entry)
#Update Url
counter+=1
if(counter<len(links_male)):
url=links_male[counter]
print(f"URL updating to: {url}")
else:
print("Done")
这将提供以下输出:picture of output
如您所见,尽管URL字符串已正确更新,但仍不更新变量html_page? 有人可以解释我为什么会这样吗? 谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)