Commit 283e2486 authored by 李康's avatar 李康

add profile code

parent 3141225a
......@@ -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()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment