python爬虫获取网页内容

import urllib
import random
import re
from urllib import request
if __name__ == "__main__":
    response = request.urlopen('https://www.doabooks.org/oai?verb=ListRecords&metadataPrefix=oai_dc&set=publisher_1088')
    html = response.read()
    html = html.decode("utf-8")
    with open('G:1.txt', 'w', encoding='utf-8') as f:
        for each in html:
            f.write(str(each))

你可能感兴趣的:(python爬虫获取网页内容)