The Top Student's Black Tech System
Chapter 48

Developing an App for Practice

1,542 words5 min read1 views
1d ago

The computer lab was quite deserted, with no one in sight.

After all, it was summer vacation, and the army of postgraduate entrance exam takers generally had no need for computers.

Lu Zhou walked over and turned on the air conditioning, casually picked a machine, sat down, entered his student ID and password, and logged in with practiced ease.

He had chosen the school computer lab mainly because programs written in Python generally ran on Linux systems. Learning Python directly in a Linux environment killed two birds with one stone.

Lu Zhou's secondhand laptop was simply too crappy. It would freeze for a while just converting a paper into PDF format. Whenever he played League of Legends, everyone else would already be laning by the time he spawned at the fountain. Installing a dual system or virtual machine was out of the question.

The books explained everything clearly enough, but I never expected this thing to be so troublesome to use... Sure enough, what's written on paper and actual hands-on operation are completely different matters. If I want to learn something, I still need practice.

Using Linux for the first time, Lu Zhou felt completely lost. He followed the instructional guide he had borrowed from the library for quite a while before finally getting the hang of it.

It had to be said that there was a reason Windows occupied such a huge market share. With its fully graphical operating system, even complete beginners who had never touched a computer could pick it up easily.

Linux, however, was different. It basically operated through command lines, and everything could be done through the keyboard. Fortunately, the school had installed a distribution with a desktop environment; otherwise, Lu Zhou really would not have known what a mouse was even for.

Of course, Linux's advantages were obvious as well. Its powerful customizability and security made it more suitable than Windows for fields such as servers. And once someone became familiar with command-line operations, their efficiency could be several times higher than on Windows. That was why so many companies asked server-side and front-end programmers one question during recruitment: did they know how to use Linux?

After familiarizing himself with the basic operations of Linux, Lu Zhou opened the Python software, flipped open his book, and stared blankly at the computer screen.

One of Python's applications is writing web crawlers. If I want to test what I've learned, this is the best place to start... But what kind of crawler should I make?

Lu Zhou could not help falling into deep thought.

Crawl blog posts from Weibo?

Crawl threads from Baidu Tieba?

That seems pretty boring.

The key was that the scraped data would be useless in his hands. If there was too much of it, he would not even have anywhere to put it.

Suddenly, an idea struck him. For some reason, he recalled the painful experiences of fighting for tickets every time he went home. It was not because his computer lagged, but because the Ministry of Railways' official website had such inhuman UI design.

Use crawler technology to scrape station, train, and remaining-ticket data from the 12306 website... This actually seems doable.

Once that thought occurred to him, Lu Zhou stopped dawdling and immediately got to work.

After all, as a typical example of Python's applications, crawler program templates were mentioned in the book. The book even provided different degrees of algorithmic improvements for different situations.

Of course, 12306 was not an ordinary BBS forum. Using it as a beginner's practice target still posed quite a challenge.

But only quite a challenge. For top student Lu, who had thoroughly mastered the entire book, it was not much of a problem. Crawlers themselves did not involve particularly difficult technology. He finished the whole program in fewer than thirty lines of code, and it ran perfectly without bugs.

Then came the scraping.

After copying the website URL into the code, Lu Zhou chose to run it, generated a spreadsheet from the data, and imported it into a folder he had created beforehand.

The computer case fan immediately began to hum, and the computer started lagging. Lines of code flashed across the black dialog box and were rapidly organized into the spreadsheet.

Watching the folder constantly fill up, Lu Zhou leaned back in his chair and sighed inwardly.

Python is damn convenient. No wonder so many experts recommend it.

As he watched line after line of data flash past, Lu Zhou actually felt as if he were getting a taste of being a hacker.

Of course, that was only an illusion. It did not even count as a feeling, since this had absolutely nothing to do with hacking. Scraping public information from a server was not illegal. At most, it was suspected of occupying someone else's server resources, which would make website administrators hate him.

That was why many "stingy" websites had anti-crawler programs. The more advanced ones either prevented users from scraping anything at all or returned only garbled text. Less advanced ones could simply monitor the number of visits and directly block the user's IP.

But 12306 was clearly not that stingy. Thinking about it, would a monopoly giant that did not even care about user experience care about a little server resource usage? As long as nobody crashed its servers, who cared?

Looking at the train data constantly piling up in the folder, Lu Zhou's eyes shifted as he wondered whether he could use it to do something.

Make a train-ticket booking website? That would be like putting pants on just to fart...

Suddenly, an idea struck Lu Zhou. What if...

I made an online ticket-booking app?

Once this spur-of-the-moment thought emerged, it uncontrollably took root and sprouted in his mind.

Although there were quite a few third-party ticket-booking apps online, there really was no official ticket-booking app. If he could make something different and sell it to interested operators, he might even earn some living expenses.

The moment money became involved, Lu Zhou immediately took it seriously and began calculating everything in his head.

Technically, independently developing an app from front end to back end was extremely difficult, far beyond writing a simple crawler program, but it was not impossible. Besides, he could ask the system about algorithms he could not solve. Spending points to look up information was itself part of the learning process.

Once he completed the reward mission and unlocked the Artificial Intelligence LV0 branch technology, those valuable experiences would surely come in handy.

The only problem was that purchasing and maintaining a server would probably cost quite a bit of money. The electricity and various maintenance costs of operating a server would likely be no small expense either...

And he had less than ten thousand yuan in his bank card. It would probably be difficult to even burn a tiny flame with that.

Gritting his teeth, Lu Zhou still decided to overcome these difficulties.

I already turned down an annual salary of five hundred thousand. What else can't I do?

Even if it flopped, he could just treat it as practice for a course project.

Thus, Lu Zhou closed the program. Instead of immediately modifying the code, he opened a Word document and began designing an outline for the app's development process, just as if he were drafting an essay outline.

Train-ticket searches must scrape real-time data, so the server performance requirements will be high. The code has to be as concise as possible!

The interface can be simple, but the information must be accurate and comprehensive. I can refer to mainstream third-party ticket-booking apps for that, but it absolutely cannot be completely similar. There has to be something innovative...

At that point, Lu Zhou lightly rubbed the keyboard with his index finger. He thought for a long time before continuing to type.

First, automatic ticket snatching. That probably doesn't count as innovation. Cheetah Browser, 360 Browser, and several other browsers already had that feature a long time ago.

But automatically refreshing tickets while left running... I don't think I've seen that before. Thinking of last winter break, when he had booked too late and several animals from his dorm had sat in front of their computers pressing F5 for nearly half an hour before finally refreshing a few tickets home, Lu Zhou deeply felt how difficult it was for ordinary people to get home for the New Year.

By constantly refreshing the official website's data, there was some mysterious chance of finding tickets. Some were tickets refunded by other users, while Lu Zhou was not sure where some of the others came from. Still, this feature was worth considering.

For example, users could set a time period and several train numbers, and the server could refresh the data for them automatically, submitting an order the instant remaining tickets appeared. Among the ticket-snatching software he had seen so far, none seemed to have this feature.

And algorithmically, it did not seem very difficult to implement.

Thinking of this, Lu Zhou looked up at the wall clock.

It was three in the afternoon!

After saving the Word document, Lu Zhou rolled up his sleeves with great enthusiasm and placed both hands on the keyboard.

Time to get to work!

End of Chapter
Novel
How was this translation?

Explore the wiki