使用 python 解析 Javascript 页面
parsing Javascript page using python
现在我正在尝试使用 python 创建一个 Javascript 页面解析器。
我尝试了很多 python 库,但我不能:(
谁能给我一个如何解析这个页面的例子:
"https://help.zoho.com/portal/en/community/zoho-crm
我想获取问题正文,或者如果有人也知道问题的名称
(对不起我的英语)
任何建议
Google python+selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
url = 'https://help.zoho.com/portal/en/community/zoho-crm'
driver = webdriver.Chrome()
driver.get(url)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located(
(By.CSS_SELECTOR, "div.TopicListLeftContainer__section"))
)
for idx, q in enumerate(driver.find_elements_by_css_selector('div.CommunityListItem__wrapper')):
a = q.find_element_by_tag_name('a')
t = q.find_element_by_css_selector('div.CommunityListItem__description')
print(idx+1, a.text)
print(t.text)
print()
driver.quit()
现在我正在尝试使用 python 创建一个 Javascript 页面解析器。
我尝试了很多 python 库,但我不能:(
谁能给我一个如何解析这个页面的例子: "https://help.zoho.com/portal/en/community/zoho-crm
我想获取问题正文,或者如果有人也知道问题的名称
(对不起我的英语) 任何建议
Google python+selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
url = 'https://help.zoho.com/portal/en/community/zoho-crm'
driver = webdriver.Chrome()
driver.get(url)
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located(
(By.CSS_SELECTOR, "div.TopicListLeftContainer__section"))
)
for idx, q in enumerate(driver.find_elements_by_css_selector('div.CommunityListItem__wrapper')):
a = q.find_element_by_tag_name('a')
t = q.find_element_by_css_selector('div.CommunityListItem__description')
print(idx+1, a.text)
print(t.text)
print()
driver.quit()