TypeError: expected string or bytes-like..

2025-07-26 01:34:17

1、代码,如下所示:import refrom crawling import downloadimport urllib.parsedef 造婷用痃link_crawler(seed_url,link_regex): """Crawl from the given seed URL following links matched b link_regex """ crawl_queue = [seed_url] while crawl_queue: url = crawl_queue.pop() html = download(url) #filter for links matching our regular expressiong for link in get_links(html): if re.match(link_regex,link): crawl_queue.append(link)def get_links(html): """Return a list of links from html""" # a regular expression to extract all links from the webpage webpage_regex = re.compile('<a[^>]+href=["\'](.*?)["\']', re.IGNORECASE) #List of all links from the webpage return webpage_regex.findall(html)link_crawler('http://example.webscraping.com','/(index|view)')

TypeError: expected string or bytes-like..TypeError: expected string or bytes-like..

5、运行后,成功。如果您觉得有帮助的话,帮我投个票吧。

TypeError: expected string or bytes-like..
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢