How to Use Python to Scrape and Export Your Weibo Favorites
Learn how to automate the download of your Sina Weibo favorites—including posts, comments, images, and video links—by simulating login with Python, saving cookies, crawling paginated collection pages, and extracting content for later processing into documents.
Python Implementation
Goal: download Sina Weibo favorites (posts, comments, images, video links) and convert them into a document.
Approach:
Simulate login to Weibo and save cookies.
Use the cookies to request the favorites page URL.
Iterate from the first page to the last, downloading each page.
Two processing steps are performed:
A. Directly download the HTML page (saved locally; viewing requires network for JS, images, etc.).
B. Parse the required Weibo content; currently the raw data is stored for later processing.
Future work will use lxml with XPath to extract text, images, and video links and convert them into a document format.
Login script reference: http://www.douban.com/note/201767245/ (used directly).
Steps
Open your Weibo favorites page (e.g., http://weibo.com/fav?leftnav=1&wvr=3.6&page=1) and note the URL prefix.
Modify the script with your username, password, and the URL prefix.
Run the script: python weibo_collect.py Result screenshots:
The variable tmpcontent contains all extracted Weibo information, awaiting further formatting.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
