Chapter 47 Develop an APP to practice
The computer room was quite deserted, and there was no one in sight.
After all, it's summer vacation at this time, and the army of graduate students generally can't use computers.
Walking over and turning on the air conditioner, Lu Zhou casually found a computer and sat down, entered his student number and password, and logged in to the computer proficiently.
The reason why I chose the computer room of the school is mainly because the programs written in python language are mainly run under the Linux system, and learning python language directly in the Linux environment can be said to kill two birds with one stone.
And Lu Zhou's own second-hand notebook is too rubbish, and the paper has to be faked for a while to be transferred to pdf format, and he has to play a masturbation and masturbate when others start to line up before he stands on the spring, and there is no need to think about the operation of installing dual systems or virtual machines.
"Although it's very clear in the book, I didn't expect this thing to be so cumbersome to use...... Sure enough, what is on paper and what is actually operated are completely different things, and if you want to learn something, you still have to rely on practice. ”
Lu Zhou, who used the Linux system for the first time, only felt blind in both eyes, and followed the instructions borrowed from the library for a while before he figured out the doorway.
I have to say that it makes sense that other people's windows systems occupy such a large market share, and the full-map operating system can be easily used even if it is a novice who has never touched the computer at all.
However, Linux is different, basically a command-line operation mode, and everything can be done through the keyboard. Fortunately, the school is equipped with a distribution with a desktop environment, otherwise Lu Zhou really doesn't know what the mouse is for.
Of course, the advantages of Linux are also obvious, and its super customizability and security make it more suitable for servers and other fields than windows. And once you are familiar with the command line operation, the efficiency will be several times higher than that of the Windows system. Therefore, when many companies recruit server front-end and back-end programmers, they will ask whether they will use the Linux system.
Familiar with the basic operation of the Linux system, Lu Zhou opened the python software, opened the book, and sat in front of the computer in a daze.
"When it comes to using Python, one of the things to do is writing web crawlers, and if you want to check your learning, it's best to start with that...... But what kind of reptile to be? ”
Lu Zhou couldn't help but fall into deep thought.
Crawling a blog post on the neck?
Posts for crawl stickers?
It seems boring.
The key is that the data that climbs down is useless in your hands, and there is no place to put it if there is more.
Suddenly, his heart moved, and somehow he recalled the painful experience of grabbing tickets every time he went home. It's not because of his computer card, but because the UI design of the official website of the Ministry of Railways is too anti-human.
"Use crawler technology to crawl the data information of each station, train number, and remaining ticket on the 12306 website...... I think this can be done. ”
As soon as he thought of this, Lu Zhou stopped grinding and immediately started working.
After all, as a typical example of the use of the Python language, the template of the crawler program is mentioned in the book, and the algorithm has been improved to varying degrees for different situations.
Of course, 12306 is not a general BBS forum after all, and it is still difficult to take this as a beginner's practice goal.
But it's just not small, but for Lu Xueba, who has already eaten the whole book, the problem is not big. The crawler itself is not too technically difficult, and the entire program was completed in less than 30 lines of code, running perfectly without bugs.
And then it's time to grab.
Copy the URL of the website behind the code, Lu Zhou chooses to run, and generates a table of the data and imports it into a pre-built folder.
Then the case fan began to hum, the computer stuttered, and lines of code flashed through the black dialog box and were quickly organized into the table.
Looking at the folders that were constantly being filled, Lu Zhou, who was leaning on the chair, sighed in his heart.
"The python language is really convenient, no wonder so many big bulls recommend this thing."
Looking at the information flashing through the lines of data, Lu Zhou really had the illusion of being addicted to hackers.
But of course, it's just an illusion, and it doesn't even feel like it, after all, this thing has nothing to do with hacking technology. It is not illegal to crawl public information from the server, at most it is suspected of crowding other people's server resources, and it will be hated by the major webmasters.
Therefore, many "stingy" websites will be set up with anti-crawler programs, and the high-tech ones either make you can't climb anything, or the ones that climb down are garbled, and the low-tech ones can also be monitored by the number of visits, directly locking your IP.
However, the 12306 website is obviously not so stingy, think about a monopoly giant that doesn't even care about user experience, will care about that bit of server resources? As long as you don't toss Lao Tzu's server on the street, who cares about you!
Looking at the continuous accumulation of train data in the folder, Lu Zhou's eyes rolled, wondering if he should use it for something?
"Make a booking website? It seems that some of them took off their pants and farted ......"
Suddenly, Lu Zhou's heart moved.
Or......
Make an app for online ticket booking?
As soon as this improvised thought came to him, it took root uncontrollably in his heart.
Although there are many third-party booking apps on the Internet, there are really no official booking apps. If he can make something different and sell it to those interested operators, maybe he can make some living expenses.
When it came to the issue of money, Lu Zhou suddenly became concerned, and began to think about it in his heart.
Technically, it is very difficult to complete the development of an app from the front-end to the back-end independently, far from writing a simple crawler program, but it is not impossible. What's more, the algorithm that can't be solved can still ask the system, and the consumption of points to query the data itself is also a learning process.
Once he's completed the bonus quest and unlocked the AI LV0 sub-technology, these valuable experiences will definitely come in handy.
However, it may cost a lot of money to buy and maintain a server, and the electricity and various maintenance costs for operating the server are probably also a lot of expenses......
And his card is less than 10,000 yuan, I'm afraid it will be difficult to burn a small flame.
Gritting his teeth, Lu Zhou still decided to overcome these difficulties.
Even gave up an annual salary of 500,000, what else can't be done?
Even if you hit the street, it doesn't hurt to do the class and set up your hands.
So, Lu Zhou closed the program, and did not rush to start changing the code, but opened the word document, just like writing the outline of a paper, and began to design the outline of the APP development process.
"Train ticket queries have to crawl real-time data, the performance requirements of the server are very high, and the code must be as concise as possible!"
"The interface can be simple, but the information must be accurate and comprehensive, which can refer to the mainstream third-party booking apps, but it must not be completely similar, and there must be something innovative......
Writing this, Lu Zhou's index finger gently rubbed the keyboard, and he thought for a long time before continuing to type on the keyboard.
"The first is automatic ticket grabbing. This should not be considered innovative, Cheetah and 360 browsers have had this feature a long time ago. ”
"But the hang-up machine automatically swipes the ticket...... I don't think I've seen it yet. Thinking that during last year's winter vacation, the tickets were booked late, and a few animals in the dormitory sat in front of the computer and pressed F5 for almost half an hour before they swiped out a few tickets to go back, and Lu Zhou deeply felt that it was not easy for the vast number of laboring people to go home for the New Year.
By constantly refreshing the data on the official website, there is a certain metaphysical probability that some tickets will be swiped, some of which are refunds from other users, and some land boats are not sure how they came out, but this function can be considered.
For example, set a time period and several trains, and the server will automatically refresh the data for the user, and submit the order at the moment when the remaining tickets appear. At present, among the several ticket-grabbing software he has seen, it seems that there is no such function.
And algorithmically, it doesn't seem to be very difficult to implement.
Thinking of this, Lu Zhou looked up at the wall clock.
It's 1 p.m.!
Saving the word document, Lu Zhou rolled up his sleeves energetically and put his hands on the keyboard.
"Get to work!"