Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
Appium-crawl
Project
Project
Details
Activity
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
李康
Appium-crawl
Commits
283e2486
Commit
283e2486
authored
Oct 15, 2019
by
李康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add profile code
parent
3141225a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
4 deletions
+36
-4
brands.py
brands.py
+36
-4
No files found.
brands.py
View file @
283e2486
...
...
@@ -10,17 +10,40 @@ brand_xpath = "/hierarchy/android.widget.FrameLayout/android.widget.FrameLayout/
"android.support.v4.view.ViewPager/android.support.v7.widget.RecyclerView/"
\
"android.widget.RelativeLayout[
%
d]"
def
scroll
(
drv
):
t1
=
time
.
time
()
drv
.
swipe
(
0
,
600
,
0
,
0
,
1000
)
t2
=
time
.
time
()
print
(
"scroll:
%
s"
%
(
t2
-
t1
))
def
getAllBrands
():
t1
=
time
.
time
()
drv
=
setUpDriver
()
t2
=
time
.
time
()
print
(
"set up driver:
%
s"
%
(
t2
-
t1
))
done
=
[]
while
True
:
t1
=
time
.
time
()
brand
=
drv
.
find_element_by_xpath
(
brand_xpath
%
1
)
t2
=
time
.
time
()
print
(
"find brand:
%
s"
%
(
t2
-
t1
))
try
:
t1
=
time
.
time
()
brand_name
=
brand
.
find_element_by_id
(
"org.c2h4.afei.beauty:id/tv_name"
)
t2
=
time
.
time
()
print
(
"find name:
%
s"
%
(
t2
-
t1
))
except
NoSuchElementException
:
brand_name
=
None
try
:
t1
=
time
.
time
()
brand_name_en
=
brand
.
find_element_by_id
(
"org.c2h4.afei.beauty:id/tv_name_en"
)
t2
=
time
.
time
()
print
(
"find english name:
%
s"
%
(
t2
-
t1
))
except
NoSuchElementException
:
brand_name_en
=
None
if
brand_name
is
not
None
:
...
...
@@ -29,23 +52,32 @@ def getAllBrands():
print
(
brand_name
.
text
)
print
(
brand_name_en
.
text
)
else
:
drv
.
swipe
(
0
,
600
,
0
,
0
,
1000
)
scroll
(
drv
)
continue
elif
brand_name_en
is
not
None
:
if
brand_name_en
.
text
not
in
done
:
done
.
append
(
brand_name_en
.
text
)
print
(
brand_name_en
.
text
)
else
:
drv
.
swipe
(
0
,
600
,
0
,
0
,
1000
)
scroll
(
drv
)
continue
else
:
drv
.
swipe
(
0
,
600
,
0
,
0
,
1000
)
scroll
(
drv
)
continue
t1
=
time
.
time
()
brand_year
=
brand
.
find_element_by_id
(
"org.c2h4.afei.beauty:id/tv_year"
)
t2
=
time
.
time
()
print
(
"find year:
%
s"
%
(
t2
-
t1
))
print
(
brand_year
.
text
)
t1
=
time
.
time
()
brand_desc
=
brand
.
find_element_by_id
(
"org.c2h4.afei.beauty:id/tv_desc"
)
t2
=
time
.
time
()
print
(
"find desc:
%
s"
%
(
t2
-
t1
))
print
(
brand_desc
.
text
)
drv
.
swipe
(
0
,
600
,
0
,
0
,
1000
)
scroll
(
drv
)
if
__name__
==
'__main__'
:
getAllBrands
()
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