本文整理汇总了Python中product.Product.parent_name方法的典型用法代码示例。如果您正苦于以下问题:Python Product.parent_name方法的具体用法?Python Product.parent_name怎么用?Python Product.parent_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product.Product
的用法示例。
在下文中一共展示了Product.parent_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from product import Product [as 别名]
# 或者: from product.Product import parent_name [as 别名]
def __init__():
#try:
clearScreen()
global driver
if (USE_FIREFOX):
binary = FirefoxBinary('/usr/bin/firefox')
driver = webdriver.Firefox() #.Firefox(firefox_binary=binary)
else:
driver = webdriver.Chrome()
with open("all_prods_in_cat.json") as json_file:
json_data = json.load(json_file)
for categ in json_data:
for produ in categ["prods"]:
loadProductPage(produ)
prod = Product()
prod.parent_name = categ["name"]
prod.parent_url = categ["url"]
if getProductVariations() is not None: #prod does has variations
lastVariation = q("body", "html")
for i in range(len(getProductVariations())):
if getProductVariations()[i].get_attribute("value") == "": #if product variation = default
scrapeProduct(prod)
if prod.accessoriesLinks is not None \
and len(prod.accessoriesLinks) > 0: #if prod has accessories
for j in range(len(prod.accessoriesLinks)):
loadProductPage(prod.accessoriesLinks[j].encode("utf-8"))
scrapeAccessorie(prod)
driver.back()
if prod.consumablesLinks is not None \
and len(prod.consumablesLinks) > 0: #if prod has consumables
for j in range(len(prod.consumablesLinks)):
loadProductPage(prod.consumablesLinks[j].encode("utf-8"))
scrapeAccessorie(prod, True)
driver.back()
continue
displayStatus("Switching product variation...", 0)
getProductVariations()[i].click()
while q("body", "html") == lastVariation:
time.sleep(0.5)
lastVariation = q("body", "html")
scrapeProduct(prod)
if prod.accessoriesLinks is not None \
and len(prod.accessoriesLinks) > 0:
for j in range(len(prod.accessoriesLinks)):
loadProductPage(prod.accessoriesLinks[j].encode("utf-8"))
scrapeAccessorie(prod)
driver.back()
if prod.consumablesLinks is not None \
and len(prod.consumablesLinks) > 0: #if prod has consumables
for j in range(len(prod.consumablesLinks)):
loadProductPage(prod.consumablesLinks[j].encode("utf-8"))
scrapeAccessorie(prod, True)
driver.back()
else: #if product does not have variations
scrapeProduct(prod)
if prod.accessoriesLinks is not None \
and len(prod.accessoriesLinks) > 0:
for j in range(len(prod.accessoriesLinks)):
loadProductPage(prod.accessoriesLinks[j].encode("utf-8"))
scrapeAccessorie(prod)
driver.back()
if prod.consumablesLinks is not None \
and len(prod.consumablesLinks) > 0: #if prod has consumables
for j in range(len(prod.consumablesLinks)):
loadProductPage(prod.consumablesLinks[j].encode("utf-8"))
scrapeAccessorie(prod, True)
driver.back()
displayStatus("Done!", 1)
speak("Crawler finished, exit code 1")
#driver.close()
'''