forked from adityab/pdf2html5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
33 lines (28 loc) · 1.08 KB
/
Copy pathserver.py
File metadata and controls
33 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import selenium
import time, sys
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://localhost/pdf2html5") # Load page
#assert "Yahoo!" in browser.title
#elem = browser.find_element_by_name("p") # Find the query box
#elem.send_keys("seleniumhq" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
elem = browser.find_element_by_xpath("//div[contains(@id,'viewer')]")
#browser.execute_script("getCanvasImage()")
# outHTML = browser.execute_script("return extract()")
maxPage = int(browser.execute_script("return pdfDoc.numPages"))
outHTML = ""
#print maxPage
for i in range(0, maxPage):
outHTML += browser.execute_script("return extract()")
browser.execute_script("goNext()")
#sleep(500)
fileStart = "<html><body>"
fileEnd = "</body></html>"
print outHTML.encode("utf8")
except NoSuchElementException:
assert 0, "can't find seleniumhq"
browser.close()