python爬虫教程:详解4种类型的爬虫技术,Python面试超详细知识点

good_name = good.find_element_by_css_selector(

‘.p-name em’).text.replace(“\n”, “–”)

商品价格

good_price = good.find_element_by_class_name(

‘p-price’).text.replace(“\n”, “:”)

评价人数

good_commit = good.find_element_by_class_name(

‘p-commit’).text.replace(“\n”, " ")

good_content = f’‘’

商品链接: {good_url}

商品名称: {good_name}

商品价格: {good_price}

评价人数: {good_commit}

\n

‘’’

print(good_content)

with open(‘jd.txt’, ‘a’, encoding=‘utf-8’) as f:

f.write(good_content)

next_tag = driver.find_element_by_class_name(‘pn-next’)

next_tag.click()

time.sleep(2)

递归调用函数

get_good(driver)

time.sleep(10)

finally:

driver.close()

if name == ‘main’:

good_name = input(‘请输入爬取商品信息:’

  • 21
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值