what have we learnt in day five

what is file?

virtual unit offered by operation system

steps to open file

1.find the file_path(file_path)

2.open file(open)

3.read or change the file(read/write)

4.save the files(flush)

5.close the file (close)

three modes to open .txt file

w:clear the file and write in

r:can only read

a:write in after the file

two ways to open .txt file

b:binary

t:text

you'd better not to use three ways below

1.r+

2.a+

3.w+

with in charge of the context

f=open()
f.read()
#close file automaticly
with open() as f
     f.read()

principle of crawler

send requests through explore to get files,through requests module analog browser gets content

process of crawler

1.send requests(filling url)

2.get context

3.choose the value you need

use of requests module

import requests
res=requests.get(url)
#wenben
res.txt
#erjinzhiliu
res.content

re module

re.S search all

re.findall() choose what you need in the context

if you need anything just(.*?)

原文地址:https://www.cnblogs.com/jimGraymane/p/11425882.html