1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- """
- @author: luojunhui
- """
- import json
- import requests
- from applications.decoratorApi import retryOnNone
- class WeixinSpider(object):
- """
- Update account articles
- """
- @classmethod
- @retryOnNone()
- def search_articles(cls, title):
- """
- search articles in wx
- :return:
- """
- url = "http://8.217.190.241:8888/crawler/wei_xin/keyword"
- payload = json.dumps({
- "keyword": title,
- "cursor": "1"
- })
- headers = {
- 'Content-Type': 'application/json'
- }
- response = requests.request("POST", url, headers=headers, data=payload)
- return response.json()
- @classmethod
- @retryOnNone()
- def get_article_text(cls, content_link):
- """
- 获取文章
- :param content_link:
- :return:
- """
- url = "http://47.98.154.124:8888/crawler/wei_xin/detail"
- payload = json.dumps({
- "content_link": content_link,
- "is_count": False,
- "is_ad": False
- })
- headers = {
- 'Content-Type': 'application/json'
- }
- # print(url)
- # print(payload)
- response = requests.request("POST", url, headers=headers, data=payload)
- print("info", response.text)
- return response.json()
- @classmethod
- @retryOnNone()
- def update_msg_list(cls, ghId, index):
- """
- :return:
- """
- url = 'http://8.217.190.241:8888/crawler/wei_xin/blogger'
- payload = {
- 'account_id': ghId,
- 'cursor': index,
- }
- print(payload)
- headers = {
- 'Content-Type': 'application/json'
- }
- response = requests.post(url, headers=headers, data=json.dumps(payload), timeout=120)
- return response.json()
- @classmethod
- @retryOnNone()
- def get_account_by_url(cls, content_url):
- """
- 通过文章获取账号信息
- :param content_url:
- :return:
- """
- response = requests.request(
- "POST",
- url='http://8.217.190.241:8888/crawler/wei_xin/account_info',
- headers={'Content-Type': 'application/json'},
- json={"content_link": content_url}
- )
- return response.json()
|