-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresolve.py
More file actions
34 lines (32 loc) · 864 Bytes
/
resolve.py
File metadata and controls
34 lines (32 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from pyquery import PyQuery as pq
import os,sys,locale
def scan_dir(dir):
files = []
if os.path.isdir(dir):
list = os.listdir(dir)
if list:
for _file in list:
tmp = "%s/%s" %(dir,_file)
if os.path.isfile(tmp):
files.append(tmp)
return files
dir = './html'
files = scan_dir(dir)
print(files)
for file in files:
with open(file,'br') as fn:
bstr = fn.read()
str = bstr.decode()
html = pq(str)
div = html("div[class!='result c-container' ]")
for line in div.items():
h = line("h3[class='t']")
if not h :
continue
a = h('a')
title = a.text()
href = a.attr('href')
print(title,href)
break