Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
macosx上的python scrapy shell::selenium.webdriver.common.action_chains.ActionChains位于0x1060d8bd0_Python_Shell_Selenium_Scrapy - Fatal编程技术网

macosx上的python scrapy shell::selenium.webdriver.common.action_chains.ActionChains位于0x1060d8bd0

macosx上的python scrapy shell::selenium.webdriver.common.action_chains.ActionChains位于0x1060d8bd0,python,shell,selenium,scrapy,Python,Shell,Selenium,Scrapy,我正试图在我的mac上用python编写一个scraper。壳牌公司给了我以下信息: In [159]: print AGM_LINK <a id="agm" class="agm" href="#" onclick="loadEvents('agm')">AGM</a> In [160]: actions.move_to_element(AGM_LINK) Out[160]: <selenium.webdriver.common.action_chains.Ac

我正试图在我的mac上用python编写一个scraper。壳牌公司给了我以下信息:

In [159]: print AGM_LINK
<a id="agm" class="agm" href="#" onclick="loadEvents('agm')">AGM</a>

In [160]: actions.move_to_element(AGM_LINK)
Out[160]: <selenium.webdriver.common.action_chains.ActionChains at 0x1060d8bd0>

In [161]: actions.click()
Out[161]: <selenium.webdriver.common.action_chains.ActionChains at 0x1060d8bd0>

In [162]: actions.perform()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-162-52a1ddc57036> in <module>()
----> 1 actions.perform()

/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.pyc in perform(self)
     72         """
     73         for action in self._actions:
---> 74             action()
     75 
     76     def click(self, on_element=None):

/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/action_chains.pyc in <lambda>()
    223         """
    224         self._actions.append(lambda: self._driver.execute(
--> 225             Command.MOVE_TO, {'element': to_element.id}))
    226         return self
    227 

AttributeError: 'unicode' object has no attribute 'id'
我似乎找不到这里的问题

早些时候,我尝试了以下方法(我在那里尝试了不同的方法):

作为一个新手,也许我正在尝试一个不同的方向!非常感谢您的帮助

ActionChain(self.driver).move_to_element(AGM_LINK).click().perform()
# Helps from :
# -----------
#     ActionChains - http://selenium-python.readthedocs.io/api.html
#     SwitchTo() - http://stackoverflow.com/a/19060830/2378780
import scrapy
from selenium import WebDriver
from selenium.webdriver.common.action_chains import ActionChains

class CompSpider(scrapy.Spider):
    name            = "CompSpider"
    allowed_domain  = ["lankabd.com"]
    start_urls      = ["http://lankabd.com/"]

    def __init__(self):
        self.driver = WebDriver.PhantomJS()

    def parse(self, response):
        self.driver.get("http://lankabd.com/portal/corporateEventsCalendarIframe.html")
        # link = response.selecor.xpath("//a[@onclick=\"loadEvents('agm')\"]")
        # yield Request(response.urljoin(link),  headers=headers, callback=self.second)

        LINK_SET   = self.driver.find_element_by_css_selector(".links")
        EVENT_LINK = self.driver.find_element_by_css_selector(".links a#agm")
        ActionChain(self.driver).move_to_element(LINK_SET).click(EVENT_LINK).perform()

        yield response

        self.driver.close()