Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf8962de

Browse files
authored
add image type in extraction (#60)
* add image src extraction* update dev requirements
1 parent180533e commitf8962de

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

‎.travis.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: python
22
sudo:required
33
dist:xenial
44
python:
5+
-3.8
56
-3.7
67
-3.6
78
-3.5

‎requirements_dev.txt‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
pip==19.1.1
2-
bumpversion==0.5.3
3-
wheel==0.33.4
4-
watchdog==0.9.0
5-
flake8==3.7.7
6-
tox==3.12.1
7-
coverage==4.5.3
8-
Sphinx==2.1.0
9-
twine==1.13.0
1+
wheel
2+
flake8
3+
tox
4+
coverage
5+
Sphinx
6+
twine
107

11-
pytest==4.6.1
12-
pytest-runner==5.1
8+
pytest
9+
pytest-runner

‎selectorlib/selectorlib.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def extract_field(element, item_type, attribute=None, formatter=None):
1414
content=element.get()
1515
elifitem_type=='Attribute':
1616
content=element.attrib.get(attribute)
17+
elifitem_type=='Image':
18+
content=element.attrib.get('src')
1719
ifformatter:
1820
content=formatter.format(content)
1921
returncontent

‎tests/data/input.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ name:
44
price:
55
css:p.price
66
type:Text
7+
image:
8+
css:img.wp-post-image
9+
type:Image
710
stock:
811
css:p.stock
912
type:Text

‎tests/data/output.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: "Bulbasaur can be seen napping in bright sunlight. There is a seed
44
\its back. By soaking up the sun\u2019s rays, the seed grows progressively larger."
55
name:Bulbasaur
66
price:"\xA3 63.00"
7+
image:'https://scrapeme.live/wp-content/uploads/2018/08/001.png'
78
related_products:
89
-{name: Fearow, price: "\xA3 95.00", sku: 9127, url: 'https://scrapeme.live/shop/Fearow/'}
910
-{name: Blastoise, price: "\xA3 76.00", sku: 5212, url: 'https://scrapeme.live/shop/Blastoise/'}

‎tests/test_selectorlib.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_content(html, input_yaml, output_yaml):
5151
formatters=formatter.Formatter.get_all()
5252
extractor=selectorlib.Extractor.from_yaml_string(input_yaml,formatters=formatters)
5353
output=extractor.extract(html,base_url=base_url)
54+
print(output)
5455
assertoutput==yaml.safe_load(output_yaml)
5556

5657

‎tox.ini‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[tox]
2-
envlist =py27, py34, py35, py36, flake8
2+
envlist =py35, py36, py37, py38, flake8
33

44
[travis]
55
python =
6+
3.8: py38
67
3.7: py37
78
3.6: py36
89
3.5: py35

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp