无法获取zomato网站的html源代码selenium、python

vaqhlq81  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(437)

我试图刮zomato网站的评论,但我无法从该网站获得源html代码。我试图获取审阅框,但它返回null或“nonetype”。这是我的密码:

from bs4 import BeautifulSoup
import requests
import re
import pandas as pd
from selenium import webdriver
import codecs
import os
import numpy as np
import pandas as pd

# import nltk

# import matplotlib.pyplot as plt

# from tensorflow import keras

os.system('cls')

PATH = "C:\\Users\\HCES\\Downloads\\chromedriver.exe"
driver = webdriver.Chrome(PATH)
i=1
html = driver.get("https://www.zomato.com/beirut/divvy-ashrafieh/reviews?page= 
{}&sort=dd&filter=reviews-dd".format(i))
driver.quit()

# soup=BeautifulSoup(html,"lxml")

# tag=soup.find_all('div', class_ = 'sc-esoVGF cHxNXn')

# print(atag)

print(html)
atmip9wb

atmip9wb1#

你做错了。
您正试图从中返回 driver.get() 但事实应该如此

driver.page_source

见下文:

i=1
driver.get("https://www.zomato.com/beirut/divvy-ashrafieh/reviews?page= {}&sort=dd&filter=reviews-dd".format(i))
page_source = driver.page_source
soup = BeautifulSoup(page_source,"lxml")

相关问题