Skip to content

Commit

Permalink
New file
Browse files Browse the repository at this point in the history
  • Loading branch information
SkaarFacee committed Apr 27, 2021
1 parent d910cc6 commit ce00146
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Binary file added geckodriver
Binary file not shown.
31 changes: 16 additions & 15 deletions spider.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ def collectLabels(driver):
def collectValues(driver):
return driver.find_elements_by_xpath("//td[contains(@class,'spec_des')]")

info=openFile("outputs/step1.json")
info=openFile("outputs/step1_part_a.json")
fin=[]
done=0
for i in info:
mini_driver=startDriver(info[i])
dic={}
dic["Name"]=mini_driver.find_element_by_xpath("//h1[contains(@class,'h1_pro_head')]").text
for label,values in zip(collectLabels(mini_driver),collectValues(mini_driver)):
dic[label.text]=values.text
fin.append(dic)
done+=1
print(done)
mini_driver.close()
#mini_driver.close()

with open("outputs/step2.json","w") as op:
json.dump(fin, op)
try:
for i in info:
mini_driver=startDriver(info[i])
dic={}
dic["Name"]=mini_driver.find_element_by_xpath("//h1[contains(@class,'h1_pro_head')]").text
for label,values in zip(collectLabels(mini_driver),collectValues(mini_driver)):
dic[label.text]=values.text
fin.append(dic)
done+=1
print(done)
mini_driver.close()
#mini_driver.close()
finally:
with open("outputs/step2.json","w") as op:
json.dump(fin, op)

0 comments on commit ce00146

Please sign in to comment.