鱼C论坛

 找回密码
 立即注册
查看: 1267|回复: 4

[已解决]怎么没结果???求助大佬

[复制链接]
发表于 2020-8-8 19:53:43 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x

                               
登录/注册后可看大图

最佳答案
2020-8-8 21:19:58
本帖最后由 1q23w31 于 2020-8-8 21:24 编辑
xiaolongren969 发表于 2020-8-8 19:59
import requests
from bs4 import BeautifulSoup
import re
import requests
from bs4 import BeautifulSoup
import re
import time
import openpyxl


def open_url(url):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0'}

    res = requests.get(url, headers=headers, timeout=500)
    return res

def main():

    host = "https://www.ebay.com.au/itm/264257008562"
    res = open_url(host)
    soup = BeautifulSoup(res.text, "html.parser")
    for info in soup.select('#msku-sel-1'):
        result = info.text
        print(result)
        print(info["id"])

   

if __name__ == "__main__":
    main()
    print("已完成")

2020-8-8 21-22-15.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2020-8-8 19:56:21 | 显示全部楼层
建议直接发下代码~
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-8-8 19:59:01 | 显示全部楼层
import requests
from bs4 import BeautifulSoup
import re
import time
import openpyxl


def open_url(url):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0'}

    res = requests.get(url, headers=headers, timeout=500)
    return res

def main():

    host = "https://www.ebay.com.au/itm/264257008562"
    res = open_url(host)
    soup = BeautifulSoup(res.text, "html.parser")
    for info in soup.find_all('select',class_="msku-sel "):
        result = info.text
        print(info["id"])

   

if __name__ == "__main__":
    main()
    print("已完成")
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-8-8 19:59:56 | 显示全部楼层
Twilight6 发表于 2020-8-8 19:56
建议直接发下代码~

import requests
from bs4 import BeautifulSoup
import re
import time
import openpyxl


def open_url(url):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0'}

    res = requests.get(url, headers=headers, timeout=500)
    return res

def main():

    host = "https://www.ebay.com.au/itm/264257008562"
    res = open_url(host)
    soup = BeautifulSoup(res.text, "html.parser")
    for info in soup.find_all('select',class_="msku-sel "):
        result = info.text
        print(info["id"])

   

if __name__ == "__main__":
    main()
    print("已完成")
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-8-8 21:19:58 | 显示全部楼层    本楼为最佳答案   
本帖最后由 1q23w31 于 2020-8-8 21:24 编辑
xiaolongren969 发表于 2020-8-8 19:59
import requests
from bs4 import BeautifulSoup
import re
import requests
from bs4 import BeautifulSoup
import re
import time
import openpyxl


def open_url(url):
    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0'}

    res = requests.get(url, headers=headers, timeout=500)
    return res

def main():

    host = "https://www.ebay.com.au/itm/264257008562"
    res = open_url(host)
    soup = BeautifulSoup(res.text, "html.parser")
    for info in soup.select('#msku-sel-1'):
        result = info.text
        print(result)
        print(info["id"])

   

if __name__ == "__main__":
    main()
    print("已完成")

2020-8-8 21-22-15.png
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-19 14:36

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表