defdfs(url, k, c, links, titles): resp = requests.get(url, headers=headers) soup = BeautifulSoup(resp.text, 'lxml') href_regex = re.compile(r'^/question') titles.append(soup.title.string) if k == c: return for a_tag in soup.find_all('a', {'href': href_regex}): href = a_tag.attrs['href'] full_url = urljoin(base_url, href) if full_url in links: continue else: links.append(full_url) l1[k - 1] = l1[k - 1] + 1 dfs(full_url, k + 1, c, links, titles)
titles, links = spider(seed_url, 4) f = open('test.txt', 'w') # 若是'wb'就表示写二进制文件 for i in range(len(titles)): # print(links[i], titles[i]) s = str(links[i]) + str(titles[i]) + '\n' f.write(s) for x in l1: f.write(str(x) + '\n') f.close()
Seems you have downgraded Yii Framework from version 2.0.16.1 to 2.0.11.
Fatal error: Cannot use ‘Object’ as class name as it is reserved in E:\Xampp\htdocs\yii2\Centenary\vendor\yiisoft\yii2\base\Object.php on line 77
.\vendor\yiisoft\yii2\base\Object.php:
* Object is the base class that implements the property feature. It has been replaced by [[BaseObject]] in version 2.0.13 because object has become a reserved word which can not be used as class name in PHP 7.2.