Я задал о трех вопросах об этом сценарии здесь. Несколько ошибок спустя я получил до сих пор. Я пытался обойти этот сценарий, но я застрял в этой части и не знаю, как его исправить. Я застрял в той части, у меня есть для петли проверка для каждого нечитанного сообщения и сохранить идентификатор разговора, чтобы я мог использовать его позже на URL.
Вот код:
#!/usr/bin/python
import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import re
email = "xxx@gmail.com"
password = "xxxxx"
print "Openning Browser"
browser = webdriver.Firefox()
browser.get("https://olx.pt/account/?ref[0][action]=myaccount&ref[0][method]=index")
print "Logging into OLX"
elem = browser.find_element_by_name("login[email]")
elem.send_keys(email)
elem = browser.find_element_by_name("login[password]")
elem.send_keys(password)
elem.send_keys(Keys.RETURN)
print "Loged into OLX"
time.sleep(5)
browser.get("https://olx.pt/myaccount/answers/")
while browser.find_elements_by_css_selector("tr.unreaded"):
print "Unreaded messages!"
unread_answers = browser.find_elements_by_css_selector("tr.unreaded")
for unread_row in unread_answers:
row_id = unread_row.get_attribute("id")
m = re.search('answer_row_(\d+)', row_id)
row_number = m.group(1)
print row_number
print "First loop"
browser.refresh()
time.sleep(5)
else:
print "All read!"
< /code>
Вот выход: < /p>
Openning Browser
Logging into OLX
Loged into OLX
Unreaded messages!
315911723
First loop
Traceback (most recent call last):
File "loginolxbackup.py", line 28, in
row_id = unread_row.get_attribute("id")
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 113, in get_attribute
resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name})
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 469, in _execute
return self._parent.execute(command, params)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: Element not found in the cache - perhaps the page has changed since it was looked up
Stacktrace:
at fxdriver.cache.getElementAt (resource://fxdriver/modules/web-element-cache.js:9407)
at Utils.getElementAt (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:8992)
at WebElement.getElementAttribute (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12099)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12614)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12619)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12561)
< /code>
HTML -страница, на которую я смотрю, - это примерно так: < /p>
...
...
Я попытался распечатать m , и я увидел, что у него есть 3 объекта, которые означают, что он получает все непрочитанные сообщения. Любой совет/помощь будет очень оценен.
Я задал о трех вопросах об этом сценарии здесь. Несколько ошибок спустя я получил до сих пор. Я пытался обойти этот сценарий, но я застрял в этой части и не знаю, как его исправить. Я застрял в той части, у меня есть для петли проверка для каждого нечитанного сообщения и сохранить идентификатор разговора, чтобы я мог использовать его позже на URL. Вот код: [code]#!/usr/bin/python import time from selenium import webdriver from selenium.webdriver.common.keys import Keys import re
while browser.find_elements_by_css_selector("tr.unreaded"): print "Unreaded messages!" unread_answers = browser.find_elements_by_css_selector("tr.unreaded") for unread_row in unread_answers: row_id = unread_row.get_attribute("id") m = re.search('answer_row_(\d+)', row_id) row_number = m.group(1) print row_number print "First loop" browser.refresh() time.sleep(5) else: print "All read!" < /code> Вот выход: < /p> Openning Browser Logging into OLX Loged into OLX Unreaded messages! 315911723 First loop Traceback (most recent call last): File "loginolxbackup.py", line 28, in row_id = unread_row.get_attribute("id") File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 113, in get_attribute resp = self._execute(Command.GET_ELEMENT_ATTRIBUTE, {'name': name}) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 469, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute self.error_handler.check_response(response) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: Element not found in the cache - perhaps the page has changed since it was looked up Stacktrace: at fxdriver.cache.getElementAt (resource://fxdriver/modules/web-element-cache.js:9407) at Utils.getElementAt (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:8992) at WebElement.getElementAttribute (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12099) at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12614) at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12619) at DelayedCommand.prototype.execute/< (file:///tmp/tmpvdAiKH/extensions/fxdriver@googlecode.com/components/command-processor.js:12561) < /code> HTML -страница, на которую я смотрю, - это примерно так: < /p>
...
...
[/code] Я попытался распечатать m , и я увидел, что у него есть 3 объекта, которые означают, что он получает все непрочитанные сообщения. Любой совет/помощь будет очень оценен.
Я пытаюсь отсортировать массив по строкам по первому значению каждой строки, затем по второму значению, если первые одинаковы, и так далее...
Например, этот массив
l_2d = np.array([ , , , ])
l_2d
array([ ,
,
,
])
Я хотел бы добавить дополнительное вертикальное пространство между первым и вторым конечными точками под одним тегом на странице Swagger от Fastapi.
Я попробовал несколько методов, но все они потерпели неудачу. Текущий блокировщик заключается в...
Я попытался настроить сервер XAMPP для локального тестирования моего собственного веб-сайта WP на своей Windows 11. XAMPP был установлен правильно — я использую порт Apache по умолчанию 80, поскольку нет конфликтов с другими приложениями, и БД была...
Я попытался настроить сервер XAMPP для локального тестирования моего собственного веб-сайта WP на своей Windows 11. XAMPP был установлен правильно — я использую порт Apache по умолчанию 80, поскольку нет конфликтов с другими приложениями, и БД была...
Я попытался настроить сервер XAMPP для локального тестирования моего собственного веб-сайта WP на своей Windows 11. XAMPP был установлен правильно — я использую порт Apache по умолчанию 80, поскольку нет конфликтов с другими приложениями, и БД была...