硒无法在Instagram网站上单击特定按钮

时间:2020-03-01 18:57:48

标签: python selenium selenium-webdriver selenium-chromedriver

您好,我无法找到一种方法来使硒单击类似https://www.instagram.com/p/B9LHHvygBnz/的帖子网页上的...按钮。

帖子一角的三个点的源代码如下:

<form method="post" action="{% url 'inputs:create' %}" enctype="multipart/form-data">{% csrf_token %}
        <div class='row'>
            <div class='col'>
                <p><input name="file" id="id_file" type="file"></p>
            </div>
        </div>
        <div class='row'>
            <div class='col'>
                <button class="btn btn-primary" type="submit">Submit</button>
            </div>
        </div>
</form>

我已经尝试了许多我可以使用的方法,但是硒没有指向它,例如我尝试过的方法:

<div class="MEAGs">
    <button class="wpO6b " type="button">
        <div class="                   Igw0E   rBNOH          YBx95       _4EzTm                                                                                                              " style="height: 24px; width: 24px;">
            <svg aria-label="More options" class="_8-yf5 " fill="#262626" height="16" viewBox="0 0 48 48" width="16">
                <circle clip-rule="evenodd" cx="8" cy="24" fill-rule="evenodd" r="4.5"></circle> 
                <circle clip-rule="evenodd" cx="24" cy="24" fill-rule="evenodd" r="4.5"></circle>
                <circle clip-rule="evenodd" cx="40" cy="24" fill-rule="evenodd" r="4.5"></circle>
           </svg>
        </div>
    </button>

self.driver.find_element_by_xpath("//div[@class='MEAGs']")

以及许多其他方式(我已经在这行特定代码上工作了2天!)

1 个答案:

答案 0 :(得分:1)

您应该始终尝试点击可以获得点击的元素,在这种情况下,请点击NbConvertApp] ERROR | Timeout waiting for execute reply (30s). Traceback (most recent call last): File "/opt/conda/bin/jupyter-nbconvert", line 11, in <module> sys.exit(main()) File "/opt/conda/lib/python3.6/site-packages/jupyter_core/application.py", line 268, in launch_instance return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs) File "/opt/conda/lib/python3.6/site-packages/traitlets/config/application.py", line 664, in launch_instance app.start() File "/opt/conda/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 340, in start self.convert_notebooks() File "/opt/conda/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 510, in convert_notebooks self.convert_single_notebook(notebook_filename) File "/opt/conda/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 481, in convert_single_notebook output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer) File "/opt/conda/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 410, in export_single_notebook output, resources = self.exporter.from_filename(notebook_filename, resources=resources) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 179, in from_filename return self.from_file(f, resources=resources, **kw) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 197, in from_file return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/pdf.py", line 171, in from_notebook_node nb, resources=resources, **kw File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/latex.py", line 88, in from_notebook_node return super(LatexExporter, self).from_notebook_node(nb, resources, **kw) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/templateexporter.py", line 307, in from_notebook_node nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 139, in from_notebook_node nb_copy, resources = self._preprocess(nb_copy, resources) File "/opt/conda/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 316, in _preprocess nbc, resc = preprocessor(nbc, resc) File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__ return self.preprocess(nb, resources) File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 405, in preprocess nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources) File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 69, in preprocess nb.cells[index], resources = self.preprocess_cell(cell, resources, index) File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 438, in preprocess_cell reply, outputs = self.run_cell(cell, cell_index, store_history) File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 571, in run_cell if self._passed_deadline(deadline): File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 541, in _passed_deadline self._handle_timeout() File "/opt/conda/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 504, in _handle_timeout raise TimeoutError("Cell execution timed out") TimeoutError: Cell execution timed out

xpath:button