美文网首页
我的编程之旅(python爬虫)

我的编程之旅(python爬虫)

作者: M子墨 | 来源:发表于2018-03-28 00:42 被阅读0次

    在这里感谢@静觅

    也学了一段时间python了,不搞一搞爬虫有点说不过去了。

    然后今天就搞了两个小爬虫:(就只是涉及简单的requests库的使用和简单的正则,但那个withopen是copy的。)

    import requests,re#https://movie.douban.com/top250?start=75&filter=for j in range(10): t=str(25*j) url="https://movie.douban.com/top250?start="+t+"&filter=" r=requests.get(url) name=re.findall('(.*?)',r.text)

        inq=re.findall('.*?inq.*?>(.*?)',r.text)

        for i in range(25):

            #def write_to_json(content):

                #with open('result.txt', 'a') as f:

                    #print(type(json.dumps(content)))

                    #f.write(json.dumps(content, ensure_ascii=False,).encode('utf-8'))

            print(name[i],'\t',point[i],'\t',inq[i])

    import requests,rej=0d=['科技','动物','建筑','风景','花海','旅游','黑白','自然','大海','高山','折页']for t in d: url="http://meisu.huaban.com/searchi.php?keyword="+t r=requests.get(url)#r=requests.get("http://meisu.huaban.com/searchi.php?keyword=插画") img=re.findall('.*?data-original.*?(http.*?=thumbs).*?',r.text) name=re.findall('',r.text)

        for i in img:

            j=j+1

        #for j in range(1000):

            im=requests.get(i)

        #for j in name:

            load='imge1/img'+str(j)+'.jpg'

            with open(load,'wb') as f:

                f.write(im.content)


    相关文章

      网友评论

          本文标题:我的编程之旅(python爬虫)

          本文链接:https://www.haomeiwen.com/subject/msbecftx.html