xiaolongren969 发表于 2020-8-8 19:53:43

怎么没结果???求助大佬

https://s1.ax1x.com/2020/08/08/aIraef.png

Twilight6 发表于 2020-8-8 19:56:21

建议直接发下代码~

xiaolongren969 发表于 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("已完成")

xiaolongren969 发表于 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("已完成")

1q23w31 发表于 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("已完成")


页: [1]
查看完整版本: 怎么没结果???求助大佬