回复 1# 447219071 - # -*- coding:utf-8 -*-
- # 需下载Python 3.5, bs4
- # pip -install bs4
-
-
- import bs4, os
- import urllib.request as url
-
- try:
- #文件路径
- file = "file:///D:/robot/desk/Script/a.txt"
- req = url.urlopen(file)
- soup = bs4.BeautifulSoup(req,'html.parser')
- for i in soup.find_all('a'):
- if i.string == '点击打开' or i.string == '点击这里进入':
- Url = url.unquote(i.get('href'))
- print("%s: %s" % (i.string,Url))
- os.system("start %s" % Url)
- except:
- print("文件不能读取")
- pass
- input("回车结束")
复制代码
|