Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- person_1 = WebDriverWait(self.driver,10).until(EC.presence_of_element_located((By.CSS_SELECTOR, "tr:nth-child(1) > td.personName > a")))
- person_1.click()
- person_profile = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, "profileSectionContent")))
- html_source = self.driver.find_element_by_xpath("//table[@id='personSummaryTable']").get_attribute("outerHTML")
- f = open('person_1_%s.html'%(company['c_name']), 'w')
- f.write(html_source.encode('utf-8'))
- f.close()
- person_path_1 = 'person_1_%s.html'%(company['c_name'])
- cookies = self.driver.get_cookies()
- with open(person_path_1) as fp:
- sel = Selector(text=fp.read())
- company['p1c_name'] = sel.xpath("//h1[@itemprop='name']/text()").extract_first().strip("n")
- company['p1c_role'] = sel.xpath("//h2[@itemprop='role']/text()").extract_first().strip("n")
- company['p1c_phoneNumber'] = sel.xpath("//div[@class='phoneNumber']/text()[position()=2]").extract_first().strip("n")
- company['p1c_email'] = sel.xpath("//span[@class='personEmail']/a/text()").extract_first().strip()
- #Click back to person list
- people = self.driver.find_element_by_xpath("//a[@id='personsearch' and @class='categoryTab personTabColor ui-tabs-anchor']")
- people.click()
- person_2 = WebDriverWait(self.driver,20).until(EC.presence_of_element_located((By.CSS_SELECTOR, "tr:nth-child(2) > td.personName > a")))
- person_2.click()
- time.sleep(4)
- person_profile = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, "profileSectionContent")))
- self.driver.save_screenshot('%s.png'%(company['c_name']))
- html_source = self.driver.find_element_by_xpath("//table[@id='personSummaryTable']").get_attribute("outerHTML")
- f = open('person_2_%s.html'%(company['c_name']), 'w')
- f.write(html_source.encode('utf-8'))
- f.close()
- person_path_2 = 'person_2_%s.html'%(company['c_name'])
- cookies = self.driver.get_cookies()
- with open(person_path_2) as fp:
- sel = Selector(text=fp.read())
- company['p2c_name'] = sel.xpath("//h1[@itemprop='name']/text()").extract_first().strip("n")
- company['p2c_role'] = sel.xpath("//h2[@itemprop='role']/text()").extract_first().strip("n")
- company['p2c_phoneNumber'] = sel.xpath("//div[@class='phoneNumber']/text()[position()=2]").extract_first().strip("n")
- company['p2c_email'] = sel.xpath("//span[@class='personEmail']/a/text()").extract_first().strip()
- yield company
- <div class="outerResults" style="">
- <div class="results searchResults" style="display: block;">
- <table cellspacing="0" id="resultGroup">
- <colgroup>
- </colgroup>
- <tbody>
- <tr>
- <td class="selector">
- <a href="#" id="p_-1454220127" title="Gary Smith" class="checkbox unchecked"> </a>
- </td>
- <td class="personName">
- <a href="#!search/profile/person?personId=-1454220127&targetid=profile">
- Gary Smith
- </a>
- </td>
- <td class="title">
- Chief Executive Officer and Co-Founder
- <input type="hidden" name="" value="Chief Executive Officer and Co-Founder" id="personTitle">
- <br>
- <div class="companyLink">
- <br>
- <a href="#!search/profile/company?companyId=104333869&targetid=profile" class="">
- Tesla Motors Inc
- </a>
- </div>
- </td>
- <td class="contact">
- <span class="unmaskContactText">Click to view this profile</span>
- <span class="detailContactMask">Email</span>
- <span class="upsellContainer" rel="upsellContactInfo"> </span><br>
- <div class="phoneNumber">
- <span class="detailContactMask">Phone</span>
- </div>
- </td>
- <td class="date">
- <span class="date" title="Last Update">
- 5/21/14
- </span>
- </td>
- </tr>
- <tr>
- <td class="selector">
- <a href="#" id="p_-1832984054" title="Tesla EVs" class="checkbox unchecked"> </a>
- </td>
- <td class="personName">
- <a href="#!search/profile/person?personId=-1832984054&targetid=profile">
- Tesla EVs
- </a>
- </td>
- <td class="title">
- Chief Executive Officer
- <input type="hidden" name="" value="Chief Executive Officer" id="personTitle">
- <br>
- <div class="companyLink">
- <br>
- <a href="#!search/profile/company?companyId=104333869&targetid=profile" class="">
- Tesla Motors Inc
- </a>
- </div>
- </td>
- <td class="contact">
- <span class="unmaskContactText">Click to view this profile</span>
- <span class="detailContactMask">Email</span>
- <span class="upsellContainer" rel="upsellContactInfo"> </span><br>
- <div class="phoneNumber">
- <span class="detailContactMask">Phone</span>
- </div>
- </td>
- <td class="date">
- <span class="date" title="Last Update">
- 6/24/15
- </span>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement