gpt4 book ai didi

python - Python Selenium Facebook市场填写表格

转载 作者:太空宇宙 更新时间:2023-11-03 20:24:50 24 4
gpt4 key购买 nike

我正在尝试在Facebook市场中填写表格。我的代码能够自动记录日志,自动填写3个输入,但是我不知道如何填写其他3个输入(位置,类别和照片)表格链接:https://m.facebook.com/marketplace/selling/item/

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

#OpenBrowser
driver = webdriver.Chrome()
driver.get("https://facebook.com/")

#Logging
email = driver.find_element_by_id('email')
password = driver.find_element_by_id('pass')
#facebook username input
email.send_keys('email')
#facebook password input
password.send_keys('pass')

time.sleep(5)
driver.find_element_by_id('loginbutton').click()
#Redicret to fb marketplace
time.sleep(2)
driver.get("https://m.facebook.com/marketplace/selling/item/"

#Filling up form
time.sleep(5)
title = driver.find_element_by_name('title').send_keys('title teste')

time.sleep(2)
price = driver.find_element_by_name('price').send_keys('50')

time.sleep(2)
description = driver.find_element_by_name('description').send_keys('description teste')

最佳答案

感谢您使用此路径(url)m.facebook.com/marketplace/selling/item的想法...移动版本更容易...您可以使用其XPath填充类别:

python_button = driver.find_elements_by_xpath("//*[@id='u_0_t']")[0]  # Category
python_button.click() # perform a click


将会打开另一个页面...然后您可以通过其 id选择类别

python_button = driver.find_element_by_id("u_6_2p")  #Furniture
python_button.click()

关于python - Python Selenium Facebook市场填写表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57915541/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com