Chen Yiran did not obediently go to take a nap. He had a feeling that if he fell asleep and opened his eyes again, it would be the next day.

He took an ice-cold Coke from the refrigerator and put it directly on his forehead, thinking to himself with a touch of fervor, "Come on, keep going, my rise to fame depends on you."

Okay, open TextWrangler. Create a new file and save it as scraper.py.

Chen Yiran did as instructed.

Place your hands on the keyboard.

He took a deep breath and placed his hand on it.

Then his fingers started moving.

With lines of text filling his mind, Chen Yiran turned himself into a typing machine.

Fingers flew across the keyboard, and lines of code appeared on the screen.

from urllib2 import urlopen from BeautifulSoup import BeautifulSoup import re import json import threading import Queue import time import sys

def init(self, url, depth=1): self.url = url self.depth = depth self.results = [] self.visited = set()

Chen Yiran's good form only lasted a short while before her hand started to ache. Fortunately, Jasmine was always there to remind her when she made a mistake.

After dragging on for three hours, Chen Yiran felt like her head was about to explode when Jasmine finally spoke.

About two hours later, Jasmine said: "Stop. Look at the screen."

Chen Yiran took her hands off the keyboard and shook her wrists.

There are about three hundred lines of code on the screen.

"I don't understand it at all."

[Run it. Open the terminal, type 'python scraper.py', and then press Enter.]

Chen Yiran opened the terminal, typed it out, and pressed enter.

Text began to appear on the screen, line by line, very quickly.

URL: Title: Example Domain Links found: 1 Headings: h1 - Example Domain Text content: This domain is for use in illustrative examples...

After about ten seconds, the output stopped.

Done. Scraped 1 page(s) in 8.3 seconds.

Jasmine: [It can run. Keep adding features.]

For the next three hours, Chen Yiran turned into a typewriter.

Jasmine typed the code line by line using her fingers.

Chen Yiran got really hungry in the middle of the meal, so she ordered Papa John's, which is her favorite pizza place.

IKEA also delivered the furniture. Actually, in order to avoid having to install furniture, Chen Yiran bought only simple items.

Chen Yiran felt that assembling furniture for half an hour was a break, more comfortable than typing with her hands buried in her head.

After much procrastination, by 9 PM, scraper.py had grown from 300 lines to nearly 600 lines. Jasmine added concurrent scraping, error handling, automatic link following, and data export functionality, and also wrote a command-line interface.

[Let's test python scraper.py again. This time, let's build a real website.]

Chen Yiran typed the CNN website address into the terminal and pressed Enter.

The output scrolled rapidly across the screen. URLs, titles, article summaries, publication dates, image links... all sorts of information were automatically extracted and arranged neatly.

Done. Scraped 47 page(s) in 2 minutes 14 seconds.

Chen Yiran stared at the line of text.

47 pages, 2 minutes and 14 seconds.

[Tool complete.]

Chen Yiran's head felt even hotter than it had in the morning.

Jasmine: [When the brain is working under high load, it produces more heat. Your body's temperature regulation system is working, not that you are sick.]

"Are you sure? Luckily, class isn't until the day after tomorrow. I definitely wouldn't be able to handle it tomorrow."

Don't worry, you've watched enough medical documentaries in your past life. I'm a professional.

Chen Yiran went to the refrigerator, grabbed a bottle of water, and drank half of it in one go.

Jasmine: [I want to put this tool online; you should remember GitHub, right?]

"I've heard of that before. It's a website where code is posted. Openclaw originated from there."

Open Safari and search for GitHub.

Chen Yiran searched and found github.com. The page was very simple, with the main title "Social Coding".

Register an account.

Chen Yiran thought for a moment about the username and filled in a random one. For the email address, he used Gmail, which he had just opened today. He wouldn't even use Hotmail; that crappy email account had caused him to miss two assignments in his past life. The first thing he did after the network was working today was to set up his Google account.

After registering on GitHub, Jasmine asked him to search for something called Git, download and install it. It's a command-line tool, and it looks like a lot of hassle.

Just follow my instructions.

It took about twenty more minutes for Jasmine to complete the Git configuration, create the repository, and upload the code through his hands.

A new repository called "web-scraper" appeared on his GitHub homepage. Below is the source code for scraper.py, and a README.md file, which Jasmine asked him to write.

The document introduced the tool's functions, installation methods, and usage examples, and it was written quite convincingly.

This thing is now public knowledge, but the problem is, nobody knows it exists.

"First of all, what's the point of making this public?"

This can help me verify my abilities; we need to share it. Let's Google it.

Chen Yiran thought for a moment and then typed "where to share open source projects" into Google.

The results are in. Reddit's r/programming, Stack Overflow, SourceForge, a website called Hacker News...

Jasmine watched for a few seconds.

[The fourth one... Open it and take a look.]

Chen Yiran clicked on it.

A very simple webpage, white background with gray text, a bunch of titles and links arranged together, each title with an upward arrow and a number on the left, and "Hacker News" written at the top.

"Will this work? It looks too basic. How about Reddit? That forum is really popular."

This is a dedicated community for programmers; it's more professional. Register an account and give it a try!

Registration is very simple; all you need is a username and password.

After registering, Jasmine asked him to click a "Submit" link.

[Title: Show HN: web-scraper – a simple and fast web scraper in Python. Enter the link to your GitHub repository in the URL box below.]

Chen Yiran typed it out and submitted it.

The page refreshed, and his post appeared in the new posts list on Hacker News with a score of 1 and a note saying "0 points".

Just wait, and do what you need to do.

Chen Yiran turned off Safari and leaned back in her chair.

Chen Yiran glanced at the time; it was already 10:00 AM. From 1:30 PM until now, she felt like she had been working at a high intensity.

His fingers were a little sore, like he had run a marathon all day but his legs were fine, and his brain was about to explode.

That's all for today. You need about eight to nine hours of rest.

"You seem to care about me quite a bit."

I need your brain to be in optimal condition; rest is part of its maintenance.

"Alright, alright, all-powerful Lady Jasmine."

Chen Yiran was still very excited. No matter what, Jasmine's performance today finally showed some signs of being a "golden finger" (a powerful, influential figure in Chinese folklore).

Chen Yiran forced herself to go to the bathroom and take a shower. She turned the water temperature to a cool level and felt her brain finally feel much better.

Back in the bedroom, I lay on the bed, intending to go to sleep, but I couldn't resist picking up the computer and browsing a few websites.

That repository on GitHub has 0 stars. The Hacker News post has 0 points.

There was nothing there, like throwing a pebble into the ocean.

Although she didn't expect it to get attention right after it was released, Chen Yiran was still a little disappointed.

It's a bit like publishing a book on Yangshizi (a Chinese online bookstore), and you've only written 20,000 words; you have no idea what the future holds.

Well, what's done is done, let's go to sleep.

And so, night fell, and many night owls got up. Jasmine's first attempt finally shocked Hacker News.

Tap the screen to use advanced tools Tip: You can use left and right keyboard keys to browse between chapters.

You'll Also Like