Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Python-100-Days
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huangkq
Python-100-Days
Commits
3e313ffb
Commit
3e313ffb
authored
Jun 09, 2018
by
jackfrued
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新了爬虫部分代码
parent
98dc244c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
taobao.py
Day66-75/code/image360/image360/spiders/taobao.py
+7
-2
No files found.
Day66-75/code/image360/image360/spiders/taobao.py
View file @
3e313ffb
# -*- coding: utf-8 -*-
from
io
import
StringIO
from
urllib.parse
import
urlencode
import
re
import
scrapy
...
...
@@ -26,6 +28,9 @@ class TaobaoSpider(scrapy.Spider):
item
=
GoodsItem
()
item
[
'price'
]
=
goods
.
xpath
(
'div[5]/div[2]/div[1]/div[1]/strong/text()'
)
.
extract_first
()
item
[
'deal'
]
=
goods
.
xpath
(
'div[5]/div[2]/div[1]/div[2]/text()'
)
.
extract_first
()
item
[
'title'
]
=
goods
.
xpath
(
'div[6]/div[2]/div[2]/a/text()'
)
.
extract_first
()
segments
=
goods
.
xpath
(
'div[6]/div[2]/div[2]/a/text()'
)
.
extract
()
title
=
StringIO
()
for
segment
in
segments
:
title
.
write
(
re
.
sub
(
'
\
s'
,
''
,
segment
))
item
[
'title'
]
=
title
.
getvalue
()
yield
item
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment