怎么没结果???求助大佬
https://s1.ax1x.com/2020/08/08/aIraef.png建议直接发下代码~ 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("已完成") 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: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]