繁体   English   中英

用nodejs抓取coffeescript和cheerio

[英]scraping with nodejs coffeescript and cheerio

我有很多带有类name的div,我需要从它们中提取文本和url

我尝试使用BeautifulSoup

for i in BeautifulSoup(page).find_all('div', {'class': 'name'}):
    print i.text
    print i.find('a').get('href')

我是nodejs / coffeescript的新手,所以很难理解它是如何工作的

$('div.name').each (i, element) ->
    console.log i

不起作用

如果您使用的是cheerio ,那么您应该可以做到这一点。

$ = cheerio.load('you html document goes here')
$('div.name').each (i, element) -> 
    console.log el

请参阅cheerio文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM