Ich möchte ich die alle Lebensmittel Titel sammeln, so dass ich Selen Markt Website market websiteSelen kann arbeiten, aber haben ein Element derzeit nicht sichtbar ist und nicht manipuliert werden kann
dies ist mein Code
crawfrom selenium import webdriver
import time
from bs4 import BeautifulSoup
chrome_path = "C:\selenium_driver_chrome\chromedriver.exe"
web = webdriver.PhantomJS(executable_path=r'C:\Users\Administrator.SIN-20150824MHC\phantomjs-2.1.1-windows\bin\phantomjs')
web.implicitly_wait(10)
web.get('http://www.pxmart.com.tw/px/ingredients_search.px')
time.sleep(1)
soup = BeautifulSoup(web.page_source,"lxml")
while len(soup.select('.ingredients-list-add')) > 0:
for ele in soup.select('.paxmart-content'):
print (ele.text)
web.find_element_by_css_selector("div.ingredients-list-add > a").click()
time.sleep(5)
soup = BeautifulSoup(web.page_source,"lxml")
ele.to_excel('pxmart.xlsx')
web.close()
Ich brauche klicken, um mehr Lebensmittel Titel zu öffnen, so dass ich die Weile wenn auf diese Weise> 0 halten klicken Sie auf Seite laden. load button
aber hier ist die Fehlermeldung
ElementNotVisibleException Traceback (most recent call last)
<ipython-input-1-93794a560872> in <module>()
15 for ele in soup.select('.paxmart-content'):
16 print (ele.text)
---> 17 web.find_element_by_css_selector("div.ingredients-list-add > a").click()
18 time.sleep(5)
19 soup = BeautifulSoup(web.page_source,"lxml")
C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in click(self)
75 def click(self):
76 """Clicks the element."""
---> 77 self._execute(Command.CLICK_ELEMENT)
78
79 def submit(self):
C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py in _execute(self, command, params)
491 params = {}
492 params['id'] = self._id
--> 493 return self._parent.execute(command, params)
494
495 def find_element(self, by=By.ID, value=None):
C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py in execute(self, driver_command, params)
254 response = self.command_executor.execute(driver_command, params)
255 if response:
--> 256 self.error_handler.check_response(response)
257 response['value'] = self._unwrap_value(
258 response.get('value', None))
C:\ProgramData\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py in check_response(self, response)
192 elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
193 raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
--> 194 raise exception_class(message, screen, stacktrace)
195
196 def _value_or_default(self, obj, key, default):
ElementNotVisibleException: Message: {"errorMessage":"Element is not currently visible and may not be manipulated","request":{"headers":{"Accept":"application/json","Accept-Encoding":"identity","Connection":"close","Content-Length":"81","Content-Type":"application/json;charset=UTF-8","Host":"127.0.0.1:55991","User-Agent":"Python http auth"},"httpVersion":"1.1","method":"POST","post":"{\"id\": \":wdc:1497706043997\", \"sessionId\": \"b09d3cb0-5360-11e7-8b78-7dbb6382b171\"}","url":"/click","urlParsed":{"anchor":"","query":"","file":"click","directory":"/","path":"/click","relative":"/click","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/click","queryKey":{},"chunks":["click"]},"urlOriginal":"/session/b09d3cb0-5360-11e7-8b78-7dbb6382b171/element/:wdc:1497706043997/click"}}
Screenshot: available via screen
Jede Hilfe geschätzt sehr würde.