ÓãCÂÛ̳

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á
²é¿´: 1759|»Ø¸´: 1

[Òѽâ¾ö]֮ǰһģһÑùµÄ¶¼Õý³£ÔËÐÐÁË

[¸´ÖÆÁ´½Ó]
·¢±íÓÚ 2023-2-13 11:11:22 | ÏÔʾȫ²¿Â¥²ã |ÔĶÁģʽ
1Óã±Ò
Õâ¸öΪʲô±¨´íѽ£¬¿´²»¶® 25VJ88H0HISK{10%_23D{NC.png
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

web = webdriver.Chrome()

web.get("http://lagou.com")

# ÕÒµ½Ä³¸öÔªËØ,µã»÷Ëü

el = web.find_element(By.XPATH, '//*[@id="changeCityBox"]/p[1]/a')

el.click()  #µã»÷ʼþ

#time.sleep(1)   #ÓÐʱ,ÒªÈÃä¯ÀÀÆ÷»ºÒ»»á¶ù

#ÕÒµ½ÊäÈë¿ò, => ÊäÈë»Ø³µ/µã»÷ËÑË÷°´Å¥
web.find_element(By.XPATH, '//*[@id="search_input"]').send_keys("python", Keys.ENTER)

#²éÕÒ´æ·ÅÊý¾ÝµÄλÖ᣽øÐÐÊý¾ÝÌáÈ¡
#ÕÒµ½Ò³ÃæÖдæ·ÅÊý¾ÝµÄËùÓеÄdiv
item__10RTO = web.find_elements(By.XPATH, '//*[@id="jobList"]/div[1]/div')
for item in item__10RTO:
    name = item.find_element(By.TAG_NAME, "a").text
    #condition = item__10RTO = web.find_element(By.XPATH, './div/div/div[1]')
    #wages = item.find_element(By.XPATH, './div/div/div[2]/span')
    print(name)

time.sleep(6000)
Traceback (most recent call last):
  File "C:\Users\misaka\PycharmProjects\pythonProject\ÅÀ³æ\µÚÎåÕÂ\seleniumµÄ¸÷ÖÖ²Ù×÷.py", line 25, in <module>
    name = item.find_element(By.TAG_NAME, "a").text
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\misaka\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 425, in find_element
    return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\misaka\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webelement.py", line 403, in _execute
    return self._parent.execute(command, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\misaka\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "C:\Users\misaka\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 245, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
  (Session info: chrome=110.0.5481.78)
Stacktrace:
Backtrace:
        (No symbol) [0x00B737D3]
        (No symbol) [0x00B08B81]
        (No symbol) [0x00A0B36D]
        (No symbol) [0x00A0E0FB]
        (No symbol) [0x00A0DFD0]
        (No symbol) [0x00A0E250]
        (No symbol) [0x00A3CFEC]
        (No symbol) [0x00A3D4BB]
        (No symbol) [0x00A32C41]
        (No symbol) [0x00A5B464]
        (No symbol) [0x00A32B96]
        (No symbol) [0x00A5B774]
        (No symbol) [0x00A71215]
        (No symbol) [0x00A5B216]
        (No symbol) [0x00A30D97]
        (No symbol) [0x00A3253D]
        GetHandleVerifier [0x00DEABF2+2510930]
        GetHandleVerifier [0x00E18EC1+2700065]
        GetHandleVerifier [0x00E1C86C+2714828]
        GetHandleVerifier [0x00C23480+645344]
        (No symbol) [0x00B10FD2]
        (No symbol) [0x00B16C68]
        (No symbol) [0x00B16D4B]
        (No symbol) [0x00B20D6B]
        BaseThreadInitThunk [0x75027D69+25]
        RtlInitializeExceptionChain [0x7716BB9B+107]
        RtlClearBits [0x7716BB1F+191]
×î¼Ñ´ð°¸
2023-2-13 11:11:23
±¾Ìû×îºóÓÉ isdkz ÓÚ 2023-2-13 11:27 ±à¼­

ÒòΪҳÃ滹ûÓÐÍê³É¼ÓÔسöÀ´£¬ËùÒÔÓà time.sleep ÈÃËüµÈ´ýÒ³ÃæÍêÈ«¼ÓÔØ
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

web = webdriver.Chrome("chromedriver.exe")

web.get("http://lagou.com")

# ÕÒµ½Ä³¸öÔªËØ,µã»÷Ëü

el = web.find_element(By.XPATH, '//*[@id="changeCityBox"]/p[1]/a')

el.click()  #µã»÷ʼþ

#time.sleep(1)   #ÓÐʱ,ÒªÈÃä¯ÀÀÆ÷»ºÒ»»á¶ù

#ÕÒµ½ÊäÈë¿ò, => ÊäÈë»Ø³µ/µã»÷ËÑË÷°´Å¥
web.find_element(By.XPATH, '//*[@id="search_input"]').send_keys("python", Keys.ENTER)

#²éÕÒ´æ·ÅÊý¾ÝµÄλÖ᣽øÐÐÊý¾ÝÌáÈ¡
#ÕÒµ½Ò³ÃæÖдæ·ÅÊý¾ÝµÄËùÓеÄdiv
time.sleep(0.1)                                                                                                 # ¼ÓÁËÕâÐÐ
item__10RTO = web.find_elements(By.XPATH, '//*[@id="jobList"]/div[1]/div')
for item in item__10RTO:
    name = item.find_element(By.TAG_NAME, "a").text
    #condition = item__10RTO = web.find_element(By.XPATH, './div/div/div[1]')
    #wages = item.find_element(By.XPATH, './div/div/div[2]/span')
    print(name)

time.sleep(6000)

×î¼Ñ´ð°¸

²é¿´ÍêÕûÄÚÈÝ

ÒòΪҳÃ滹ûÓÐÍê³É¼ÓÔسöÀ´£¬ËùÒÔÓà time.sleep ÈÃËüµÈ´ýÒ³ÃæÍêÈ«¼ÓÔØ
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
·¢±íÓÚ 2023-2-13 11:11:23 | ÏÔʾȫ²¿Â¥²ã    ±¾Â¥Îª×î¼Ñ´ð°¸   
±¾Ìû×îºóÓÉ isdkz ÓÚ 2023-2-13 11:27 ±à¼­

ÒòΪҳÃ滹ûÓÐÍê³É¼ÓÔسöÀ´£¬ËùÒÔÓà time.sleep ÈÃËüµÈ´ýÒ³ÃæÍêÈ«¼ÓÔØ
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

web = webdriver.Chrome("chromedriver.exe")

web.get("http://lagou.com")

# ÕÒµ½Ä³¸öÔªËØ,µã»÷Ëü

el = web.find_element(By.XPATH, '//*[@id="changeCityBox"]/p[1]/a')

el.click()  #µã»÷ʼþ

#time.sleep(1)   #ÓÐʱ,ÒªÈÃä¯ÀÀÆ÷»ºÒ»»á¶ù

#ÕÒµ½ÊäÈë¿ò, => ÊäÈë»Ø³µ/µã»÷ËÑË÷°´Å¥
web.find_element(By.XPATH, '//*[@id="search_input"]').send_keys("python", Keys.ENTER)

#²éÕÒ´æ·ÅÊý¾ÝµÄλÖ᣽øÐÐÊý¾ÝÌáÈ¡
#ÕÒµ½Ò³ÃæÖдæ·ÅÊý¾ÝµÄËùÓеÄdiv
time.sleep(0.1)                                                                                                 # ¼ÓÁËÕâÐÐ
item__10RTO = web.find_elements(By.XPATH, '//*[@id="jobList"]/div[1]/div')
for item in item__10RTO:
    name = item.find_element(By.TAG_NAME, "a").text
    #condition = item__10RTO = web.find_element(By.XPATH, './div/div/div[1]')
    #wages = item.find_element(By.XPATH, './div/div/div[2]/span')
    print(name)

time.sleep(6000)
ÏëÖªµÀС¼×Óã×î½üÔÚ×öɶ£¿Çë·ÃÎÊ -> ilovefishc.com
»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

ÄúÐèÒªµÇ¼ºó²Å¿ÉÒÔ»ØÌû µÇ¼ | Á¢¼´×¢²á

±¾°æ»ý·Ö¹æÔò

СºÚÎÝ|ÊÖ»ú°æ|Archiver|ÓãC¹¤×÷ÊÒ ( ÔÁICP±¸18085999ºÅ-1 | ÔÁ¹«Íø°²±¸ 44051102000585ºÅ)

GMT+8, 2024-11-16 10:25

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí