-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain2.py
35 lines (29 loc) · 826 Bytes
/
main2.py
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
import re
import urllib.request
import time
from bs4 import BeautifulSoup
from session import Session
import re
from const import *
from util import *
def get_song(res):
def func1(r):
print("func1")
html_maybe = re.search("(片頭曲「)+.+(」)+",r.text).group(0)
return BeautifulSoup(html_maybe,'html.parser').text
def func2(r):
# is table
print("func2")
soup=BeautifulSoup(r.content,'html.parser')
soup=soup.find(id="主題曲").parent.find_next_sibling()
return soup
# op=defense(res,func1,func2)
op=func2(res)
print(op)
# main
session=Session()
for line in open(IN_FILE_NAME,"r",encoding="UTF-8"):
line=line.strip()
print(line)
res = session.request("GET", "https://zh.wikipedia.org/wiki/"+line)
arr= get_song(res)