# 爬取人人词典，出现小问题，希望有人能帮帮忙

**URL:** <https://forum.freemdict.com/t/topic/2254>\
**Category:** 技术交流与词典编修\
**Tags:** python, ﻿英语\
**Created:** [2020 年6 月 7 日 09:58 UTC](https://forum.freemdict.com/t/topic/2254 "2020-06-07T09:58:36Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 7 日 09:58 UTC](https://forum.freemdict.com/t/topic/2254/1 "2020-06-07T09:58:37Z")

</div>

使用 python 3.8.1 ， BeautifulSoup ，requests 代码如下， 目前希望打印的结果v. n.能换行， 再者就是目前是输入的单词在链接上， 该怎么写 ， 让其自动爬取单词 释义呢， 然后是保存到一个文件里面去 ， 目前只是打印到控制台上了。 自己先练练手 ， 代码也不是很了解。

 ![image](https://forumcdn.freemdict.com/uploads/default/original/2X/3/3d4546f46e92fd442f8c23b3041b29e6cd9ecf2f.png)

下图是控制台的打印结果

 ![image](https://forumcdn.freemdict.com/uploads/default/original/2X/5/5193c59bad394123bf31dcbf76ec0799bc27d241.jpeg)

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年6 月 7 日 10:12 UTC](https://forum.freemdict.com/t/topic/2254/2 "2020-06-07T10:12:08Z")

</div>

> [@青稚Quentin](#):
>
> 目前希望打印的结果v. n.能换行

将 v. n. 替换成前面带一个换行符的再打印。

> [@青稚Quentin](#):
>
> 再者就是目前是输入的单词在链接上， 该怎么写 ， 让其自动爬取单词 释义呢， 然后是保存到一个文件里面去 ，

> **[Python3 教程 | 菜鸟教程](https://www.runoob.com/python3/python3-tutorial.html)**
>
> Python 3 教程 Python 的 3.0 版本，常被称为 Python 3000，或简称 Py3k。相对于 Python 的早期版本，这是一个较大的升级。为了不带入过多的累赘，Python 3.0 在设计的时候没有考虑向下兼容。 Python 介绍及安装教程我们在Python 2.X 版本的教程中已有介绍，这里就不再赘述。 你也可以点击 Python2.x与3​​.x版本区别 来查看两者的不同。 本教程主要针对 Pyt..

---

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 7 日 10:15 UTC](https://forum.freemdict.com/t/topic/2254/4 "2020-06-07T10:15:38Z")

</div>

谢谢 ！ v. n. 是直接 用

soup = BeautifulSoup(html, ‘html.parser’)  
div = soup.find(name=‘div’, attrs={‘class’: ‘listBox’})  
取出来的 我不知道该怎么加进去 😂

---

<div class="post-metadata">

作者： ![atauzki](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/atauzki/32/1365_2.png) [@atauzki](https://forum.freemdict.com/u/atauzki)\
发布日期： [2020 年6 月 7 日 10:17 UTC](https://forum.freemdict.com/t/topic/2254/5 "2020-06-07T10:17:44Z")

</div>

> **[Built-in Types](https://docs.python.org/3.8/library/stdtypes.html?highlight=replace#str.replace)**
>
> The following sections describe the standard types that are built into the interpreter. The principal built-in types are numerics, sequences, mappings, classes, instances and exceptions. Some colle...

或者用正则

> **[re — Regular expression operations](https://docs.python.org/3.8/library/re.html?highlight=re%20sub#re.sub)**
>
> Source code: Lib/re/ This module provides regular expression matching operations similar to those found in Perl. Both patterns and strings to be searched can be Unicode strings ( str) as well as 8-...

---

<div class="post-metadata">

作者： ![hua](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/hua/32/11090_2.png) [@hua](https://forum.freemdict.com/u/hua)\
发布日期： [2020 年6 月 7 日 10:26 UTC](https://forum.freemdict.com/t/topic/2254/7 "2020-06-07T10:26:36Z")

</div>

本来就没标签的。

---

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 7 日 10:27 UTC](https://forum.freemdict.com/t/topic/2254/8 "2020-06-07T10:27:26Z")

</div>

那 。。。。。 如果有哪位爬取的代码 ， 可以看看就好了

---

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 7 日 10:45 UTC](https://forum.freemdict.com/t/topic/2254/10 "2020-06-07T10:45:08Z")

</div>

我改了一下 ， 现在这个效果

 ![image](https://forumcdn.freemdict.com/uploads/default/original/2X/a/acbd28685df98271fbe3bf07ee252d81e0e769db.jpeg)

---

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 8 日 05:28 UTC](https://forum.freemdict.com/t/topic/2254/12 "2020-06-08T05:28:48Z")

</div>

我抓取的是 人人词典的单词、释义， 后面抓取的例句的代码还没写呢， 这次抓取是想练练手， 想尝试一下自己做mdx

---

<div class="post-metadata">

作者： ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
发布日期： [2020 年6 月 8 日 06:39 UTC](https://forum.freemdict.com/t/topic/2254/14 "2020-06-08T06:39:21Z")

</div>

这样啊 ！ 我只是练手， 看见论坛有人求人人词典的mdx文件 ， 就拿它试手了。
