【发布时间】:2020-09-29 18:23:28
【问题描述】:
我使用 nodejs 从站点 steam 获取所有链接。
在站点链接中(例如):
- https://steamcommunity.com/market/listings/730/Horizon%20Case
- https://steamcommunity.com/market/listings/730/Chroma%203%20Case
- 等
我明白了:
- https://steamcommunity.com/market/listings/730/Horizon%20Case(好)
- https://steamcommunity.com/market/listings/730/Chroma%20Case(错误)
我的代码:
var link_part1 = 'https://steamcommunity.com/market/search?category_730_ItemSet%5B%5D=any&category_730_ProPlayer%5B%5D=any&category_730_StickerCapsule%5B%5D=any&category_730_TournamentTeam%5B%5D=any&category_730_Weapon%5B%5D=any&category_730_Type%5B%5D=tag_CSGO_Type_WeaponCase&appid=730&q=case#p1'
var link_part2 = '_price_asc'
var number_page = 1
request(link_part1+number_page+link_part2, function(err, resp, html) {
if (!err){
const $ = cheerio.load(html);
for (i=0; i<10; i++) {
let box = $("a.market_listing_row_link").eq(i).attr('href')
console.log(box);
}
} else {
console.log("Error");
}
});
我做错了什么???
【问题讨论】:
标签: node.js request href cheerio steam