You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.4 KiB
60 lines
2.4 KiB
# 导入
|
|
from DrissionPage import Chromium, ChromiumOptions
|
|
|
|
# 连接浏览器
|
|
# browser = Chromium()
|
|
# 获取标签页对象
|
|
# tab = browser.latest_tab
|
|
# 访问网页
|
|
# tab.get('https://etax.chinatax.gov.cn')
|
|
|
|
|
|
def inner_page(page):
|
|
"""
|
|
|
|
"""
|
|
a_tab = page.ele('xpath:/html/body/div[4]/div/div/div[3]/ul/li[3]/a') # 缴税记录
|
|
a_tab.click()
|
|
table_list = page.eles('xpath:/html/body/div[4]/div/div/div[3]/div[3]/div/div/div/div[2]/div/table/tbody/tr') # 凭证
|
|
for tr in table_list:
|
|
href = tr.ele('@tag()=a') # 跳转链接 证明pdf 需要下载
|
|
href.click() # 跳转下载
|
|
tab.wait.doc_loaded() # 等待文档加载完毕
|
|
page.get_screenshot(path='tmp', name='pic.jpg', full_page=False) # 下载发票
|
|
break
|
|
|
|
co = ChromiumOptions()
|
|
co.set_argument("--remote-debugging-port", "9222")
|
|
browser = Chromium(co) # 创建浏览器对象
|
|
browser.set.retry_times(10) # 设置整体运行参数
|
|
tab = browser.latest_tab # 获取Tab对象
|
|
tab.get("https://etax.chinatax.gov.cn")
|
|
# #app > div.header-user > div > div.navbar-container > ul > li:nth-child(3) > a
|
|
# #app > div.header-user > div > div.navbar-container > ul > li.active > a
|
|
# ele = tab.ele("#app > div.header-user > div > div.navbar-container > ul > li:nth-child(3) > a")
|
|
try:
|
|
ele = tab.ele('xpath://*[@id="app"]/div[1]/div/div[2]/ul/li[3]/a') # 我要查询
|
|
ele.click()
|
|
tab.ele('xpath://*[@id="app"]/div[2]/div/div/div[1]/div[2]/a[1]').click() # 申报查询
|
|
|
|
text = tab.ele('xpath://*[@id="app"]/div[2]/div/div[2]/div[2]/div[1]/div[1]').text # 待缴税款
|
|
print(text)
|
|
text1 = tab.ele('xpath://*[@id="app"]/div[2]/div/div[2]/div[2]/div[1]/div[2]').text # 可申请退税金额
|
|
print(text1)
|
|
ele = tab.ele('xpath://*[@id="app"]/div[2]/div/div[2]/div[1]/label[2]/span') # 已完成标签
|
|
ele.click()
|
|
|
|
table_list = tab.eles('xpath://*[@id="app"]/div[2]/div/div[2]/div[3]/div/div[3]/table/tbody/tr')
|
|
# for tr in table_list:
|
|
# # td = tab.eles('@tag:td')
|
|
# print(tr.texts()) # 获取所有的文本
|
|
# # //*[@id="app"]/div[2]/div/div[2]/div[3]/div/div[3]/table/tbody/tr[2]/td[6]/div/a[1]
|
|
# href = tr.ele('@tag()=a') # 跳转链接
|
|
# href.click()
|
|
# inner_page(tab)
|
|
# break
|
|
except Exception as e:
|
|
print(f"e is => {e}")
|
|
browser.quit() # 关闭浏览器
|
|
|
|
browser.quit() # 关闭浏览器
|