Main function:
package com.tianyu;import java.sql.connection;import java.sql.drivermanager;import Com.alibaba.fastjson.jsonobject;public class main {public static string game_url = "http://ka.game.163.com/service/cardsvc/taohao?id=12374";p ublic static string driver_url = "Jdbc:mysql://localhost:3306/tianyu?user=root&password=bianbian";p ublic static String active_url = "http://s.webcgi.163.com/tianyu-active-code/activate_code?callback= Jquery16405689243660308421_1425463449791&[email protected]&[email protected]&code= 88888888&phone=18319381102&server_id=4&r=0.936580075416714&_=1425463512824 ";p ublic static String active_cookie = "usertrack=c+5+hltugfwfjrdqnnwnag==; _ntes_nnid= 4904adbda635e2b4c3300430f25a4b60,1424916988772; _ntes_nuid=4904adbda635e2b4c3300430f25a4b60; Province=020; city=0755; vjuids=-a362cb80.14bd01c11ac.0.919a8084; ne_analysis_trace_id=1425459633430; pgr_n_f_l_n3= 42bfb7239ea4e51514254596334311653; vjlast=1425125675.1425459653.11; vinfo_n_f_l_n3= 42bfb7239ea4e515.1.2.1425125675451.1425264968449.1425462798644; s_n_f_l_n3=42bfb7239ea4e5151425459633463; ntes_sess=sg7cr1yodzysskecondwkoznsblpgde8tnwnabr_wa3a449dfwf.1pejrggb8aenb.xrex3o1lrrk_ 1egymhpddpgqydc1uerop9tyiwive8danewxi3akfykjwj7kqxb37fwi96wgfwp.w8osqocipt.; s_info=1425462851|0|##| [email protected]; [email protected]|1425462851|0|other|00&99|gud&1425383570&other# gud&440300#10#0#0|&0| | [email protected]; anticsrf=335fae91042b660cf700404af040b584];p Ublic static void main (String[] args) {try {class.forname ("Com.mysql.jdbc.Driver"); Connection conn = drivermanager.getconnection (Driver_url); while (true) {callurl call = new callurl (); Jsonobject obj = call.getjsonbyTianyu (Game_url); System.out.println (Active_url.replaceall ("code=88888888", "code=" +obj.getjsonobject ("Data"). GetString (" Used_key "))); Gameactive.active (Active_url.replaceall ("code=88888888", "code=" +obj.getjsonobject ("Data"). GetString (" Used_key ")), active_cookie); Savejson.savedata (Conn, obj);}} catch (exception e) {e.printstacktrace ();}}
Account Activation class:
Package Com.tianyu;import Java.io.inputstream;import Java.net.httpurlconnection;import Java.net.URL;public class gameactive {public static Boolean Active (String active_url,string cookie_url) {try {thread.sleep (10000); URL u = new URL (active_url); HttpURLConnection conn = (httpurlconnection) u.openconnection (); Conn.setconnecttimeout (5*1000); Conn.setrequestmethod ("GET"); Conn.setrequestproperty ("Cookie", Cookie_url);//conn.connect (); InputStream stream = Conn.getinputstream (); byte[] data = Callurl.streamtobyte (stream); Stream.Close (); System.out.println (new String (data, "utf-8"));} catch (Exception e) {e.printstacktrace ();} finally {}return false;}}
Get the CAPTCHA data class:
package com.tianyu;import java.io.bytearrayoutputstream;import java.io.ioexception;import java.io.inputstream;import java.net.httpurlconnection;import java.net.url;import com.alibaba.fastjson.jsonobject;public class callurl {public jsonobject Getjsonbytianyu (String url) {JSONObject obj = null; httpurlconnection conn = null; try { url u = new url (URL); conn = (HttpURLConnection) u.openconnection (); Conn.setconnecttimeout (5*1000); Conn.setrequestmethod ("GET");inputstream instream = Conn.getinputstream (); byte[] data =streamtobyte (instream); string&nbsP;result = new string (data, "UTF-8"); Return obj.parseobject (result);} catch (exception e) {e.printstacktrace ();} finally {} return null;} Public static byte[] streamtobyte (Inputstream stream) throws ioexception { Bytearrayoutputstream swapstream = new bytearrayoutputstream (); byte[] buff = new byte[100]; int rc = 0; while ((Rc = stream.read (buff, 0, 100)) > 0) { swapstream.write (Buff, 0,  RC); } byte[] in2b = Swapstream.tobytearray (); return in2b;}}
Save the Activation code class:
Package Com.tianyu;import Java.sql.connection;import Java.sql.preparedstatement;import java.sql.SQLException; Import Com.alibaba.fastjson.jsonobject;public class Savejson {public static String sql = ' INSERT INTO Tianyu (Status,use_c Ount,used_key) VALUES (?,?,?) "; public static Boolean SaveData (Connection conn, jsonobject obj) {try {preparedstatement statement = Conn.preparestatement (SQL); statement.setstring (1, obj.getstring ("status")); Jsonobject o = obj.getjsonobject ("Data"), Statement.setstring (2, o.getstring ("Use_count")), Statement.setstring (3, O.getstring ("Used_key")); System.out.println (obj); return Statement.execute ();} catch (SQLException e) {e.printstacktrace ();} return false;}}
finally attached pom.xml
<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " xsi:schemalocation=" http://maven.apache.org/POM/4.0.0 http:// Maven.apache.org/xsd/maven-4.0.0.xsd "> <modelVersion>4.0.0</modelVersion> <groupId>com.tianyu</groupId> <artifactId>TianYu</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>TianYu</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceencoding>utf-8</ project.build.sourceencoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactid>junit</artifactid> <version>3.8.1</version> < scope>test</scope> </dependency> <dependency> <groupid>mysql</groupid > <artifactId>mysql-connector-java</artifactId> <version>5.1.27</version> </dependency> <dependency> <groupId>com.alibaba</groupId>< artifactid>fastjson</artifactid><version>1.2.4</version> </ Dependency> </dependencies></project>
The game is good, but don't offs oh. Hunger marketing go CRAP!!!
NetEase Oracle-Rob Game Verification code version-java