想要使用 python 将 url 链接添加到 .csv 数据源

发布于 2024-08-27 11:34:32 字数 444 浏览 5 评论 0原文

我浏览了当前的相关问题,但没有找到与我的需求类似的内容。

我正在使用 zencart 创建联属商店 - 现在的问题之一是 zencart 不是为重定向和联属商店而设计的,但它可以做到。我将改变商店,使其像展示价格的展示店一样。

有一个名为 easy populate 的 mod,它允许我上传数据源。这一切都很好,但是我的附属链接不会出现在每个产品中。我可以在上传数据源并转到每个产品,然后将其添加为带有重定向链接的图像后手动执行此操作 - 但是,当有超过 500 个项目时,这将是一项长期重复且耗时的工作。

有人告诉我,我可以在将数据上传到 zencart 之前将链接添加到数据源,这应该使用 python 来完成。我已经读了好几天有关 python 的文章了,感觉我在寻找错误的东西。我想知道是否有人可以建议我完成这项工作的最简单方法。

我希望这个问题有意义,

谢谢

abs

ive looked through the current related questions but have not managed to find anything similar to my needs.

Im in the process of creating a affiliate store using zencart - now one of the issues is that zencart is not designed for redirects and affiliate stores but it can be done. I will be changing the store so it acts like a showcase store showing prices.

There is a mod called easy populate which allows me to upload datafeeds. This is all well and good however my affiliate link will not be in each product. I can do it manually after uploading the data feed and going to each product and then adding it as an image with a redirect link - However when there are over 500 items its going to be a long repetitive and time consuming job.

I have been told that I can add the links to the data feed before uploading it to zencart and this should be done using python. Ive been reading about python for several days now and feel im looking for the wrong things. I was wondering if someone could please advise the simplest way for me to get this done.

I hope the question makes sense

thanks

abs

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

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

发布评论

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

评论(2

牛↙奶布丁 2024-09-03 11:34:32

您可以使用 csv 模块制作一个 python 脚本,如下所示:

>>> import csv
>>> cartWriter = csv.writer(open('yourcart.csv', 'wb'))
>>> cartWriter.writerow(['Product', 'yourinfo', 'yourlink'])

您需要知道如何链接应该格式化,希望它可以使用 csv 文件中存在的其他参数来组成。

You could craft a python script using csv module like this:

>>> import csv
>>> cartWriter = csv.writer(open('yourcart.csv', 'wb'))
>>> cartWriter.writerow(['Product', 'yourinfo', 'yourlink'])

You need to know how link should be formatted hoping that it could be composed using the other parameters present on csv file.

凶凌 2024-09-03 11:34:32

首先,按照 systempuntoout 告诉您的方式使用 CSV 模块,其次,您需要将标题更改为:

mimetype='text/csv'
Content-Disposition = 'attachment; filename=name_of_your_file.csv'

执行此操作的方法很大程度上取决于您的网站实现。在纯 Python 中,您可能会使用 HttpResponse 对象来做到这一点。在 django 中也是如此,但有一些快捷方式

您可以在 showmedo 上找到如何使用 Python 创建 CSV 文件的视频。然而它不是免费的。

现在,要提供下载 CSV 的链接,这取决于您的网站。它背后的技术是什么:纯Python、Django、Pylons、Tubogear?

如果您无法回答这个问题,您应该在尝试对其进行更改之前向您的老板询问有关您的基础架构的培训。

First, use the CSV module as systempuntoout told you, secondly, you will want to change your header to:

mimetype='text/csv'
Content-Disposition = 'attachment; filename=name_of_your_file.csv'

The way to do it depends very much of your website implementation. In pure Python you would probably do that with an HttpResponse object. In django, as well, but there are some shortcuts.

You can find a video demonstrating how to create CSV files with Python on showmedo. It's not free however.

Now, to provide a link to download the CSV, this depends of your Website. What is the technology behinds it : pure Python, Django, Pylons, Tubogear ?

If you can't answer the question, you should ask your boss a training about your infrastructure before trying to make change to it.

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