You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1a61180
Browse filesBrowse the repository at this point in the historyBrowse files
4.Now you need to setup webhooks. We need to deploy the django project online
36
-
and make it available for facebook to make requests and facebook allows only
37
-
https urls. [Your development environment, in the cloud](http://c9.io) is the
38
-
best option I found online and it’s free for a basic app. Create a workspace
39
-
in c9 and choose **Django **as platform. Now you will be directed to your
40
-
online workspace.
22
+
4. 现在,你需要设置网络钩子。我们需要将该django项目部署在线,并且使其可为facebook创建请求,而facebook只允许https url。[Your development environment, in the cloud](http://c9.io)是我发现在线的最佳选择,而它对于一个基本的应用是免费的。在c9中创建工作空间,选择**Django**作为平台。现在,你将被定向到你的在线工作空间。
41
23
42
-
5.From the workspace use the below command to create a django app.
24
+
5.在工作区中,使用下面的命令来创建一个django应用。
43
25
44
26
```python
45
27
46
28
django-admin.py startapp jokebot
47
29
48
30
```
49
31
50
-
This should create an app jokebot.
32
+
这应该创建一个应用jokebot。
51
33
52
-
Go to [settings.py](http://settings.py) file in the workspace, find
scraping-digital-comics-information-from-comixology/ "Web Scraping with Python
26
-
- Scraping Digital Comics information from Comixology" )
27
1
28
2
原文:[Web Scraping with Python - Scraping Digital Comics information from Comixology](http://felipegalvao.com.br/blog/2016/05/24/web-scraping-with-python-scraping-digital-comics-information-from-comixology/)
29
3
30
4
---
31
5
32
-
## Introduction
6
+
## 简介
33
7
34
8
Well, after having talked about the previous analysis that I did about
quadrinhos-digitais-parte-1-analise-do-site-para-web-scraping/), we'll now
9
+
Comixology in the [previous post in this series](http://felipegalvao.com.br/blog/2016/05/01/comixology-analise-de-quadrinhos-digitais-parte-1-analise-do-site-para-web-scraping/), we'll now
38
10
talk about the web scraping with Python, the code itself. As we have already
39
11
talked about, we will use requests to make requests to web pages and lxml with
40
12
Xpath for parsing and information extraction from the desired pages. Let's go.
41
13
42
-
## Starting to write the code
14
+
## 开始写代码
43
15
44
16
To start the conversation, we will import the necessary libraries, requests
45
17
and, from lxml, the html function. To access the HTML parts, we will use
46
18
Xpath. So, let's talk about Xpath before we move on to the code. I'll try to
47
19
keep it short.
48
20
49
-
## Xpath: What it is and how to use it
21
+
## Xpath:它是什么以及如何使用它
50
22
51
23
Xpath is a query language used to extract content from XML / HTML documents.
52
24
It can be used to extract information form nodes and attributes, being very
@@ -224,22 +196,20 @@ something that does not exist in the document, an empty list is returned.
224
196
And now that we saw this simple example, let's move on to something more
225
197
complex and fun.
226
198
227
-
## Returning to the code
199
+
## 回到代码
228
200
229
201
Now that we know what Xpath is about, let's use it to extract the Comixology
230
202
website itself. For web scraping with Xpath, one of our best friends will be
231
203
the "Inspect Element" feature from Chrome or Firefox. It will allow us to see
232
204
the source code and the HTML structure and path for a certain element in the
233
205
page.
234
206
235
-
Let's move on to the Publishers section on Comixology. ([click
236
-
here](https://www.comixology.com/browse-publisher)). We will extract our code
207
+
Let's move on to the Publishers section on Comixology. ([点击这里](https://www.comixology.com/browse-publisher)). We will extract our code
237
208
defining the function and creating an empty list which will hold the Publisher
238
209
links that we will extract. As we talked on the first post, we will define the
239
210
page quantity manually (4 pages, so, we will have a for page in range (1,5)),
240
211
and we will pass through each of them. If we go to the site and change to the
241
-
next page, we will see that the link becomes: https://www.comixology.com
242
-
/browse-publisher?publisherList_pg=2. If we change it back to the first page,
212
+
next page, we will see that the link becomes: https://www.comixology.com/browse-publisher?publisherList_pg=2. If we change it back to the first page,
243
213
the final part of the link turn back to 1. The first pages of the code will be
244
214
as following:
245
215
@@ -282,10 +252,7 @@ class "list FeaturedPublisherList", items from the All Publishers table are in
282
252
a div that has the class "list publisherList". Let's make our Xpath sentence
[](http://felipegalvao.com.br/blog/wp-content/uploads/2016/05/comixology_2_3-publisher_few_pages.png)
460
420
461
421
B - Publisher with few pages
462
422
463
423
|
464
424
465
-
[](http://felipegalvao.com.br/blog/wp-content/uploads/2016/05/comixology_2_4-publisher_many_pages.png)
469
426
470
427
C - Publisher with many pages
471
428
@@ -484,10 +441,7 @@ available, the Publisher has only one page of Series. Simple, isn't it? Well,
484
441
let's inspect some elements to see how we are going to build the Xpath
485
442
sentence, and then we can go to the code:
486
443
487
-
[](http://felipegalvao.com.br/blog/wp-content/uploads/2016/05/comixology_2_5-series_pages.jpg)
491
445
492
446
Path to quantity of Series
493
447
@@ -651,7 +605,7 @@ export periodically our data in order to avoid that.
0 commit comments