liuyuqi-dellpc 1 year ago
parent
commit
150ac59e4f
1 changed files with 53 additions and 3 deletions
  1. 53 3
      crawl_xiaohua/crawl_xiaohua/extractor/qinimg.py

+ 53 - 3
crawl_xiaohua/crawl_xiaohua/extractor/qinimg.py

@@ -201,9 +201,31 @@ insert into qinimg_girl_detail (uid,name,pic_index,createtime,url) values ('{}',
         if not os.path.exists("data/{}".format(name)):
             os.mkdir("data/{}".format(name))
         with open("data/{}/{}.jpg".format(name, index), "wb") as f:
-            f.write(self.sess.get(url, headers=self._header).content)
+            header ={
+                "authority": "qinimg.woshitu.cfd",
+                "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
+                "accept-language": "en-US,en;q=0.9",
+                "cache-control": "max-age=0",
+                "dnt": "1",
+                "if-modified-since": "Wed, 13 Sep 2023 00:24:47 GMT",
+                "if-none-match": '"6501014f-6e9f"',
+                "referer": "https://www.qinimg.com/",
+                "sec-ch-ua": '"Chromium";v="116", "Not)A;Brand";v="24", "Microsoft Edge";v="116"',
+                "sec-ch-ua-mobile": "?0",
+                "sec-ch-ua-platform": '"Windows"',
+                "sec-fetch-dest": "document",
+                "sec-fetch-mode": "navigate",
+                "sec-fetch-site": "cross-site",
+                "sec-fetch-user": "?1",
+                "upgrade-insecure-requests": "1",
+                "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36(KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.76"
+                }
+            res = self.sess.get(url, headers=header)
+            f.write(res.content)
+            print("download pic: " + url)
+
         sql='''
-        update qinimg_girl_detail set is_download = 1 where url = '{}'
+        UPDATE qinimg_girl_detail set is_download = 1 where url = '{}'
         '''
         self.cursor.execute(sql.format(url))
         self.conn.commit()
@@ -254,7 +276,35 @@ select * from qinimg_config where key = '{}'
         ''' release '''
         self.cursor.close()
         self.conn.close()
-        
+
+
+class Girl:
+    ''' girl model '''
+    def __init__(self, name, uid, createtime, url, isdelete=0):
+        self.name = name
+        self.uid = uid
+        self.createtime = createtime
+        self.url = url
+        self.isdelete = isdelete
+
+class GirlDetail:
+    ''' girl detail model '''  
+    def __init__(self, uid, name, pic_index, url, is_download, createtime):
+        self.uid = uid
+        self.name = name
+        self.pic_index = pic_index
+        self.url = url
+        self.is_download = is_download
+        self.createtime = createtime
+    
+class Config:
+    ''' config model '''
+    def __init__(self, key, value, isdelete=0, desc=""):
+        self.key = key
+        self.value = value
+        self.isdelete=isdelete
+        self.desc=desc
+
 if __name__ == "__main__":
     qinimg = Qinimg()
     qinimg.run()