20200529 - 위 챗 애플 릿 백 스테이지 통계 데이터 추출 (보완 필요)

2291 단어 파충python
from selenium import webdriver
from time import sleep

list=[]
chromedriver = r'C:\Users\lusy\AppData\Local\Programs\Python\Python36-32\chromedriver.exe'
driver = webdriver.Chrome(chromedriver)
chrome_opts = webdriver.ChromeOptions()
chrome_opts.add_argument("--headless")
driver.get('https://mp.weixin.qq.com/')
driver.find_element_by_xpath('//*[@id="header"]/div[2]/div/div/div[2]/a').click()

#           ,     
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/form/div[1]/div[1]/div/span/input').clear()
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/form/div[1]/div[1]/div/span/input').send_keys('[email protected]')
sleep(1)

#          ,     
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/form/div[1]/div[2]/div/span/input').clear()
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/form/div[1]/div[2]/div/span/input').send_keys('TCM2vFKP')
sleep(1)

#     
#     
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div/div/div[1]/form/div[4]/a').click()
sleep(5)
print('     ,      ')
a = input()

driver.find_element_by_xpath('/html/body/div[1]/div[3]/div/div[1]/div/dl[3]/dt/a').click()
print('    ')
sleep(1)

driver.switch_to.frame('js_iframe')
sleep(2)

# print('      ')
# driver.find_element_by_xpath('//*[@id="topTab"]/ul/li[3]/a').click()
# sleep(1)
#
# print('      ')
# driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div[3]/div[2]/div[2]/div[2]/div[1]/span[2]').click()
# sleep(1)
#
# for i in range(1, 8):
#     dau_xpath = ('/html/body/div[1]/div[2]/div/div[3]/div[2]/div[2]/div[2]/div[2]/div[1]/div[1]/div/div[2]/p[%s]/span[2]/span' % i)
#     dau = driver.find_element_by_xpath(dau_xpath).text
#     list.append(dau)

print('      ')
driver.find_element_by_xpath('//*[@id="topTab"]/ul/li[5]/a').click()
sleep(2)

driver.find_element_by_xpath('//*[contains(@id,"highcharts")]')
a = driver.find_elements_by_xpath('//*[contains(@id,"highcharts")]')
print(a[6].text)

sleep(1)

좋은 웹페이지 즐겨찾기