Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于初始化 #19

Open
WangDongWei515 opened this issue Jul 12, 2020 · 3 comments
Open

关于初始化 #19

WangDongWei515 opened this issue Jul 12, 2020 · 3 comments

Comments

@WangDongWei515
Copy link

请问下如果想把之前得到的数据都删了,重新跑自己需要的数据,是把data里的数据都删了就好了吗?
还有想请问下如果只是爬自己感兴趣的目标集的话
items = set(response.xpath(
'//a[contains(@href, "/item/")]/@href').re(r'/item/[A-Za-z0-9%\u4E00-\u9FA5]+'))
for item in items:
new_url = 'https://baike.baidu.com'+urllib.parse.unquote(item)
new_item_name = re.sub(
'/', '', re.sub('https://baike.baidu.com/item/', '', new_url))
if new_item_name not in self.olds:
yield response.follow(new_url, callback=self.parse)
把这里直接注释掉,然后在网址那里改成自己需要的就行了吗?

@lixiang0
Copy link
Owner

第一个问题,是的。
第二个问题,不是很理解你要做什么,不过值爬你需要的词条只需要修改yield语句,只产生你感兴趣的链接就行了。

@WangDongWei515
Copy link
Author

第一个问题,是的。
第二个问题,不是很理解你要做什么,不过值爬你需要的词条只需要修改yield语句,只产生你感兴趣的链接就行了。

已经修改好了,十分感谢!

@zihao-miao
Copy link

第一个问题,是的。
第二个问题,不是很理解你要做什么,不过值爬你需要的词条只需要修改yield语句,只产生你感兴趣的链接就行了。

已经修改好了,十分感谢!

怎么修改的,大佬请赐教,我这个只能爬取中文名,其他的关系无法爬取,我是在Windows上运行的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants