After loading the container, it runs in JavaScript You have to crawl the binding page over there.
So I'm going to scratch it after loading
#!/usr/bin/python
# # -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
"""
1.
"""
driver = webdriver.Chrome("C:\\chrome\\chromedriver.exe")
driver.get('http://~~~~~~')
html = driver.page_source
soup = BeautifulSoup(html,"lxml")
print(soup)
ranks = soup.findAll("div", id="Grid")
I did it as above, but it doesn't work. What's the problem?
python
Replace id="Grid"
with {"id":"Grid"}
.
ranks = soup.findAll("div", {"id":"Grid"})
If you just want to scratch the elements in the div,
ranks = soup.findAll("div", {"id":"Grid"}).findChildren()
Try it.
Please refer to the stack overflow question below.
How to find children of nodes using Beautiful Soup
© 2024 OneMinuteCode. All rights reserved.