Python automatically logs on to Renren and accesses the nearest visitor instance. python automatically logs on to Renren.
This article describes how to use python to automatically log on to Renren and access the nearest visitor.
The specific method is as follows:
#-*-Coding: gbk-*-# In import OS from xml. dom import minidom import re import urllib import urllib2 import cookielib import datetime import time from urllib2 import URLError, HTTPError # def renren_login (logfile, username, password) found on the login module online: logfile. write (str (datetime. datetime. now () + 'renren/r/N') cj = cookielib. cookieJar () post_data = urllib. urlencode ({'email ': username, 'Password': password, }) Path = 'HTTP: // your opener = urllib2.build _ opener (urllib2.HTTPCookieProcessor (cj) urllib2.install _ opener (opener) req = urllib2.Request (path, post_data) try: conn = urllib2.urlopen (req) failed t URLError, e: print 'urlerror 'logfile. write ('urlerror: '+ str (e. code) + '/r/N') return False when T HTTPError, e: logfile. write ('HTTP Error: '+ e. reason + '/r/N') return False if conn. get Url () = 'HTTP: // www.renren.com/home': print 'success 'logfile. write ('Task finished/r/N') open('login_renren.html ', 'w '). write (conn. read () return conn. read () else: print 'Task failed' logfile. write ('Task failed/r/N') # The generated log file file_object = open ("log.txt", 'w') login_index = renren_login (file_object, 'username ', 'Password') # change to the logon username and password # parse resolution webpage r1 = re. compile (''' http: // www.renren.com/profile.do \? Portal = homeFootprint & ref = home_footprint & id = \ d {9} ''') li = r1.findall (open ("login_renren.html", "r "). read () # Put the resolved recently visited address in the dictionary url_dict ={} for item in li: print item url_dict.setdefault (item) # access Recent visitors for item in url_dict.iterkeys (): OS. startfile (item)
I hope this article will help you with Python programming.
How can I handle the verification code for python Renren's Automatic Logon? Otherwise, automatic logon cannot be implemented.
What should I do if I encounter a verification code? There are two solutions:
-
1. google's verification code, cool
-
2. simple verification code: the number of characters is limited. It only uses simple translation or rotation to add noise without being distorted. This kind of verification code can still be processed. The general idea is to rotate it back, noise Removal,
Divide a single character, divide it, and then use the feature extraction method (such as PCA) to reduce the dimension and generate a feature library, and then compare the verification code with the feature library. This is complicated. I can't finish a blog post.
.
-
3. In fact, some verification codes are still very weak. I won't name them here. Anyway, I have extracted very accurate verification codes through the 2 method, SO 2 is actually feasible.
Questions about Renren Web visitors
Browsing others' albums or logs from new things will not appear on the "Recent visitors" on his homepage, but the log will show "who has read this log"
As long as you browse others' homepages, they will appear in others' recent visitors.