Article From:https://www.cnblogs.com/zhangziyan/p/9123071.html

From the Japanese learning website &gt, select the reading page to get the name list and introduction:

The web page is shown in the following figure:

PythonThe code is as follows:

import requests
import re

html=requests.get('http://jp.tingroom.com/yuedu/yd300p/')
html.encoding='utf-8'
# print(html.text)
chinese=re.findall('color: #039;">(.*?)</a>',html.text,re.S)
order=chinese
i=0
for each in chinese:
    print(each)
    num=re.findall('(\d+)',each)
    order[i]=num[1]
    i+=1

japanese=re.findall('color:#666666;">(.*?)</span>',html.text,re.S)
j=0
for each in japanese:
    eachrow='Chapter {0}: {1}'.format(order[j],each)
    print('writing...')
    print(eachrow)
    print('saved')
    fp=open('content\\content.txt','a')
    fp.write(eachrow+'\n')
    j+=1

PycharmThe output is as follows:

300289 Norway forest (Chinese Japanese contrast) second chapters
300A comparative study of 288 Norway’s forests (Chinese and Japanese) Chapter one
300Selected Chinese and Japanese Comparative Reading 287 Mr. Fujino: Selected Works
300Selected Chinese and Japanese contrast reading 286 Natsume Soseki I am the first chapter of cat.
300A selection of Chinese and Japanese Comparative Reading of 285 handles
300A choice between Chinese and Japanese in a comparative reading of 284
300Selected Chinese and Japanese Comparative Reading 283 last words
300A selected Chinese version of the Japanese language, a comparative reading of 282 doctors
300A selection of the 281 forms of the Chinese language contrast reading
300A selection of Chinese and Japanese contrast reading 280 and the target
300A choice between Chinese and Japanese in a comparative reading of 279
300A selection of Chinese and Japanese in contrast to the 278 intentions of reading
300A selection of Chinese and Japanese contrast reading 277
300A selected Chinese version of the Japanese language is a comparative reading of 276 stars
300275 white dolomitic melancholy
300Selected Chinese and Japanese Comparative Reading 274 learning and reading
300A selection of 273 thieves who read Japanese in contrast to reading the persimmons.
300The Japanese text of the selected Chinese text is more than 272.
300This is not your home. 271
300Selected Chinese and Japanese contrast reading 270 affectation and affectation
writing…
The 289th chapter: the second chapter is about the past twenty years.
saved
writing…
288th: Norway’s forest (Chinese and Japanese control): a sad song of Hanburg Airport.
saved
writing…
The 287th is: in the selected works of Fujino, the Japanese language is compared with the Tokyo dialect. On the…
saved
writing…
The 286th article: Natsume Soseki, I am a cat (Chinese and Japanese control). I am a cat, a cat and a Natsume Soseki.
saved
writing…
The 285th is: the hillock hospital.
saved
writing…
The 284th chapter: the male and the female. It is the same.
saved
writing…
The 283rd part is: “the” and “the”.
saved
writing…
The 282nd part: to the doctor. …
saved
writing…
The 281st chapter is: the “basin” and “the”.
saved
writing…
The 280th one is: three, too.
saved
writing…
279th. This is the house.
saved
writing…
The 278th part: Ueki’s excellent. It’s…
saved
writing…
The 277th part is: “the son of the son”.
saved
writing…
The 276th chapter: the night and the temple.
saved
writing…
The 275th part is: one of the most important things.
saved
writing…
The 274th part is: first, Japanese, and other studies.
saved
writing…
The 273rd chapter: the dark night, the two men, if they are male,
saved
writing…
The 272nd chapter is: the birth of a soldier, the day of the birth, the battle of the rat, and the smell of the rat.
saved
writing…
The 271st chapter: the outskirts of Tokyo, who lived in the village of Kimura, and the failure of the liquor.
saved
writing…
The 270th chapter: the new silk dress, skirt, and skirt.
saved

The generated introduction TXT text is like the following figure:

Leave a Reply

Your email address will not be published. Required fields are marked *