python
1def get_page(url): 2 try: 3 import requests 4 import bs4 5 import lxml 6 res = requests.get(url) 7 soup=bs4.BeautifulSoup(res.content,"lxml") 8 return soup 9 except: 10 return "" 11 12def get_all_target(page): 13 list=[] 14 for elem in get_page(page).select("a"): 15 list.append(elem.get("href")) 16 return list 17 18def union(p,q): 19 for e in q: 20 if e not in p: 21 p.append(e) 22 23 24def crawl_web(seed): 25 tocrawl = [seed] 26 crawled = [] 27 while tocrawl: 28 page = tocrawl.pop() 29 if page not in crawled: 30 union(tocrawl, get_all_target(get_page(page))) 31 crawled.append(page) 32 return crawled 33
上記で AttributeError: 'str' object has no attribute 'select' がでます。 何故ですか?
また、ページ数を指定しないと無限化しますか? (web上のメールアドレスなどの自動検索ツール作成中)
読んでくださいーー;
https://teratail.com/help/question-tips#questionTips1
回答1件
あなたの回答
tips
プレビュー