使用 urllib 更改表的值

发布于 2024-10-30 09:23:33 字数 746 浏览 4 评论 0原文

我正在尝试使用 urllib 更改表中的值。我相信做到这一点的方法是使用 post 请求。然而我没有取得任何成功并且完全迷失了。

感谢您可以分享的任何帮助。

这是我正在尝试编辑的页面(editme.php),

<html>
<body>
    <div>
        <table>
            <tr>
                <td id="changme">1</td>
            </tr>
        </table>
    </div>
</body>
</html>

我正在本地运行,我想将单元格中的值更改为其他值。我正在尝试使用以下方法来做到这一点:

import urllib
import urllib2
from BeautifulSoup import BeautifulSoup

values = urllib.urlencode({'changeme' : 'i have changed'})
f = urllib.urlopen("http://localhost/editme.php",values)
readdata = urllib.urlopen("http://localhost/editme.php")
print  BeautifulSoup(readdata).prettify()

I am trying to change the values in a table using urllib. I believe the way to do this is by using post request. However I am having no success whatsoever and am completely lost.

Any help you can share is appreciated.

Here is the page I am trying to edit (editme.php)

<html>
<body>
    <div>
        <table>
            <tr>
                <td id="changme">1</td>
            </tr>
        </table>
    </div>
</body>
</html>

I am running things locally and I want to change the value in cell w/ id="changeme" to something else. I am trying to do that using this:

import urllib
import urllib2
from BeautifulSoup import BeautifulSoup

values = urllib.urlencode({'changeme' : 'i have changed'})
f = urllib.urlopen("http://localhost/editme.php",values)
readdata = urllib.urlopen("http://localhost/editme.php")
print  BeautifulSoup(readdata).prettify()

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

辞取 2024-11-06 09:23:33

你所问的没有任何意义。您必须更改模板或在服务器上呈现表格的任何内容,而不是通过下载/上传。

Does not make any sense what you are asking. You have to change the template or whatever is rendering your table on the SERVER and not through download/upload.

呆° 2024-11-06 09:23:33

Em...抱歉,但是您无法通过 urllib 更改该表值,除非 php 脚本这样做。 editme.php 是一个“纯”html 文件。

Em... sorry, but there is no way you'll change that table value via urllib, unless the php script does that. And the editme.php is a "pure" html file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文