Self-study Android Practice words app (1)-Android's Hello Word with Youdao dictionary anti-crawler hack

Source: Internet
Author: User
Tags at sign sqlite
1. Preface

Idle to be bored. The phone is something that comes into contact every day. What is the easiest way to get in touch with a program? Think of some people saying that both front and back are all stacks. Oh, look at the HTML5 full stack.

I'd say it's interesting to have more contact. Write back end every day. It's not a business layer. It's not a big algorithm. The front end is much more interesting. Of course, I'm the old one. It's not ag.vue,react. It's just that the water in the front is very deep.

Next, the app is going to accomplish those goals.

1. Look up the words (this is too simple)

2. Translation (call Youdao)

3. Sentence analysis (originally in the thinking of English is not what the law.) and then someone did it. Embed directly.

4. Word matching (to suggest some of the same words according to some messy rules)

5. Crawler articles (tentative)

Relevant technologies and content to be used

1.sqlite Local database, (store word database)

Use of 2.webView

3.http Request emulation

4. Three-party tool Navicat, used for data transmission MSYQL to Sqlite,fiddler, used to grab packets

5. To be Android's Hello Word

2. Start up 1. Download Android Studio

Run Hello Word

Android Studio has a Gradle build running the problem of a very long time is very annoying to start the first time fast. And then it got stuck. Baidu's methods have also been used. It didn't work out well. Later cleared the cache inexplicably good.

2. Real-Machine Commissioning

The most difficult thing at first is that some of the options don't know where to go. Some regular use is not very good. The real machine here is the newspaper equipment can not find. The solution was found on the Internet. The button didn't see where it was. Then the next 2 places will be fine.

The one on the right is my own. The following is what people tell me.

3. Layout

Novice. I dragged the control. It's like WinForm. TextView was dragged in the middle. It's on the top when it's shown. This asks someone else. Change the inside part into a relativelayout. And then it's normal.

4. Get control, add event

I understand the process, the code will not, with the mouth programming

And the pit daddy is. This thing I do not have Baidu to. In fact, this is not a problem for watching video learning. I came straight up to the hard work. It's OK to ask someone else. And then someone helped me out. Findviewbyid. It's not hard. is to get the control and add the event. Okay, after the stumbling block. Something else should not be a problem. I think so.

5. Gets the value of the text box. Filled TextView

There is no pear here, at first I wrote a complex. I don't know, this charsuquence is the value of the text box. I have been re-acquired again.

6. Study SQLite

This is easy. A bunch of online tutorials. Think of a friend said to the Baidu programming. Baidu looked down. There is an abstract class. But the first thing to think about is to see the code. This database will not be initialized. You'll need to create it every time. And then you see that it's not there. To the location in the local. Copy out. However, the Help class for this database. This initialization is of little use to me. My data is expected to be stored in advance. This is just a query. But this SQLite SQL statement is not compatible with MySQL. Some of the keywords are not the same as the field type.

There's a lot of chatter here. The time of the Baidu. See the method that has 2 queries. One is the SQL statement. One is a parameterized query method. The object of this position in the SQL statement is passed in as a parameter. It seems to remember that there are 7 parameters ... It's for people who don't have SQL. It really feels like learning something is useful backstage stuff. Android will also use it. The idea of an idiom comprehend by analogy. This is very important.

7.SQLite Data Initialization

Locate the location of the sqllite under the data directory. Copy and copy the Word data from MySQL. The data source of this word is made before it is OK. I thought I had written an article. I didn't think so. The format of the data source is a bit of a problem. Icode. Remember to parse this thing for a while. To accurately get the Unicode thing inside. Then the conversion was taken. Then the data is transferred. This SQL statement is not compatible. If you are using a SQL file, you cannot execute it. Fortunately, the navicat has a sync function. A small bug.sql is estimated to be enclosed in single quotation marks. Then if there is a single quotation mark in the field, the error will be made. When it's in sync. Turn off the transaction. There are 10 of them that seem to be in trouble. But it should not be used. It takes a long time to transfer. It took about 3 hours. It's not too small. After you have a database. The rest is almost the same as backstage. Query the database.

8.WebView Research

There's a lot of this stuff on Android. The reason for this is that we have found a web site of sentence analysis. Originally wanted to interface access. But their interface is too primitive. Returns the HTML snippet. Or embed the site directly.

The first little pit is the loadurl Jump browser. Baidu has been a bit. Try to solve a few. Anyway, just set up a bunch of parameters. or JS or something. JS is also a pit behind.

The second is that the page is white screen after load. Not shown. I didn't find it. I guess it's the reason for HTTPS. I was the first to visit Baidu. There is https. I have no access to this thing.

The third hop browser on the Web is a click-through link. Mine is a load on the jump. This should be the cause of the redirect. It's the same as jumping. It also reminds me of the mastery. This is a front-end or with a bit of knowledge. Page redirection.

The fourth is not a small pit is the normal technical research bar. Execute JS. First let the input box get the focus he will empty the hint text. This is very simple. He had a onclik incident. The rest is to write the message to the page.

The fifth one is a small hole. It is the time to execute JS when the page is loaded and executed. The web looked for the page to load up the event. There was an incident in the webviewclient. It's just going to happen once. There's a bug that's not going to work. But that's a lot of the time. Hundred will execute three times. No solution was found. Later, a tag variable was added. After execution. It's not going to work out.

Sixth user login information issue. WebView The user information is saved. Do not do the simulation login. Log in manually once.

9. Network requests and UI updates, network permissions

This is supposed to be what we said earlier. It is not possible to make a network request in the main thread. The child thread cannot perform interface operations. Baidu. It's a little bit messy. 3 keywords. Thread,handler, Runnable Tiger. It's just like WinForm here. But WinForm is not as strict as Android. Android does not do this directly. Yes, there is a problem with permissions. That's the network right. This also needs to be configured

10.jar Package Introduction

Httphelper need to use an Apache package. The use of Maven.gradle this is not a very good feeling. But I don't know where the convulsions are. Fortunately, the reference to the local jar package is Android. But it's better than Java. The web is a reference to a local jar package. Too much friendship. Java The web has to be a private one. Otherwise, add a local repository. A generic reference. To pack all sorts of questions. Android will just throw it in the Libs. This is almost as easy as. Net. This gradle hole. The code runs on the line. All the way to Rome.

11.activity Research

This Baidu content is also quite a lot of. The main thing is how to create. Then how to show the pass of the parameter. It's going well. No pits.

12. Youdao Interface Research

Here comes the point. The goblin is a little torture. As of the time I wrote this article. not yet. But I'm sure I have a way to get it through.

At first I wanted to be simple. I thought it was just an ordinary interface. The result returns ERRORCODE:50. Baidu a bit. Someone has studied it. There are also articles. But the method is not good. I'm combing it. This is Baidu to the article. The author is also very clear about this. But the comment says it's out of the question. I looked at the source code. It seems that the salt value has indeed been changed. It is not scary to know the problem. No, No. So the first step is not to call the phone first.

Using Python to decipher the proper translation anti-crawler mechanism

75294947

It's going to take a fiddler here. This gripper can be simulated. A small artifact. In fact, I have found a problem with the mobile phone bag. I've discovered a bit of a mistake. The equals sign In this case has been escaped. The one I'm looking for is a bit of a problem with the httphelper. The right thing to do is a=b. & That sort of thing.

The above article knows that this interface is authenticated locally. Because there is time. So my first guess is that this verification message will not have an expiration time. I used the same header to get my hair up. There are no errors. It seems that there is no validation time. It's just a time stamp.

It's actually a salt that can be fixed. We don't need to create new one every time. Then it is based on the article to find the salt value. First download JS. And then like the article said to format. Save to JS. This helps to parse the syntax structure.

We request information based on the browser. Direct search Typoresult search. This is just a keyword. Here's the compression confusion. In fact, the role of the highway is not particularly large. And then look at sign signature. There's a d in there. This is the variable that puts the salt value. You know, it's not good. Search. Put it in idea. With Ctrl and left. Jump right in the past.

OK, the key information has been obtained. The next step is simulation.

Part of the simulation is to find a different chant. First, make the right request. The size of the body. It is also possible to go directly to it. This is true. The wrong thing is 16. And then it's the right one. It's a little bit more than the phone. There are 2 important pieces of information in the header, one is the cookie and Referer there is no word here. It will return error. Of course, the premise is that the body parameters to be correct. This is the line that was requested on the Web page. The time in the book is not expired. You can always use it. In fact, the HTTP header detection is not particularly reliable. The next step is to make the phone's request Just like a browser. Fill in the two parameters.

Look at the code. Set the information in this location. A map was added to the header information. ... After writing, I found that the necessary information on the above there is ....

Run. The result is good ... Well, I was wondering if there were any other pits. The result is good ... I changed the place where the body was escaped. The salt value was replaced before.

I don't know what the author thinks. To escape from the body. I'm going to turn around. You're in there. You've lost the equal number.

13. Conclusion

To be honest, the one with the right. I said it would take some time. I didn't think the next step was success.

Through this Hello Word's Android app. found that Android content is not very much. There are also similarities with other languages. UI and network requests. The WinForm will look familiar. SQL data and the code behind Android has been familiar with Java. As for the properties of the control. This is done by the front end and WinForm can guess the event. Httphelp Er. This background language will encounter this. C#.java. And the last data JSON returned is almost universal text Transfer protocol. So it's not a big problem. And then the main thread is the HTTP protocol . This is the main line of mastery. The requestheader,requestbody. This is the point. There are also cookies. To say a mock request. It's not going to go around. Cookie domain, The. Path under that domain name is used for the path below the domain name. General use/. Indicates that all paths are used. And there is the expiration time. There are a few header properties left. Note that the data format that I passed is content-type. You can observe the normal POST request and upload the file. This is not the same. And the accept says what kind of data I want. Spring MVC will have bugs in some cases.

The rest of the app is to query SQLite data. Do the word matching rules. And then grab some English articles. Maybe that's it. But honestly. An Zuojin is just an interface to the bearer, this behind the things and Android related really feel not too much.

I am not proficient in the background. I'm not just writing interfaces. I just do everything. Everything is not good.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.