Skip to content

Commit

Permalink
spy anti
Browse files Browse the repository at this point in the history
  • Loading branch information
tttwwy committed Feb 28, 2015
1 parent a5caa0a commit b51d83e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions rss/app/rss/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def __init__(self):
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11',
'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36']

def get_items(self,openid):
link = "http://weixin.sogou.com/gzh?openid={0}&repp=1".format(openid)
def get_html(self,url):
user_agent = self.useragent[random.randint(0,len(self.useragent)-1)]
headers = {
'User-Agent': user_agent,
Expand All @@ -58,11 +56,15 @@ def get_items(self,openid):
'Host': 'weixin.sogou.com',
'DNT': '1',
'Cache-Control': 'max-age=0',
}

request = urllib2.Request(link, headers=headers)
}
request = urllib2.Request(url, headers=headers)
response = urllib2.urlopen(request)
html = response.read()
return html
def get_items(self,openid):
link = "http://weixin.sogou.com/gzh?openid={0}&repp=1".format(openid)

html = self.get_html(link)

logging.info(openid)
logging.info(link)
Expand Down Expand Up @@ -98,7 +100,7 @@ def get_items(self,openid):

def get_content(self, item):
link = item["link"]
html = urllib2.urlopen(link).read()
html = self.get_html(link)

html_inner = re.search(
r"<div class=\"rich_media_inner\">[\s\S]*<div class=\"rich_media_tool\" id=\"js_toobar\">", html).group()
Expand Down

0 comments on commit b51d83e

Please sign in to comment.