Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
253 views
in Technique[技术] by (71.8m points)

python - 如何整理重复的链接python(How to sort out duplicate links python)

Let me start out I'm a complete noob and this is my first coding project.

(首先,我是一个完整的菜鸟,这是我的第一个编码项目。)

So please forgive me if I'm doing it wrong!

(所以,如果我做错了,请原谅我!)

Currently if I run my script it prints out a list of URL's from the website I'm trying to automatically update.

(目前,如果我运行脚本,它将打印出我尝试自动更新的网站的URL列表。)

Well, it gives me the ending of the URL, so I manually add the 1st part on.

(好吧,它给了我URL的结尾,因此我手动添加了第一部分。)

I have all the urls stored under 'Temp'.

(我所有的网址都存储在“临时”下。)

I've tried to separate them using lists my the following

(我试图使用以下列表将它们分开)

AR = ["http://www.Puppyfind.com/s/" + str(temp)]
AR = list(set(AR))
Print (AR)

If I put it on the same indentation as the line of code that gets me the URLs it feeds me back urls like this

(如果我将其放在与获取我的网址的代码行相同的缩进中,则会像这样向我提供网址)

['http://www.puppyfind.com/s/url1']
['http://www.puppyfind.com/s/url1']
['http://www.puppyfind.com/s/url2']
['http://www.puppyfind.com/s/url2']
['http://www.puppyfind.com/s/url3']
['http://www.puppyfind.com/s/url3']
['http://www.puppyfind.com/s/url4']
['http://www.puppyfind.com/s/url4']
['http://www.puppyfind.com/s/url5']
['http://www.puppyfind.com/s/url5']
['http://www.puppyfind.com/s/url6']
['http://www.puppyfind.com/s/url6']
['http://www.puppyfind.com/s/url7']
['http://www.puppyfind.com/s/url7']

If I put it with no I indentation then it feeds be back just the last link which is

(如果我不加缩进,那么它只返回最后一个链接)

['http://www.puppyfind.com/s/url7']

I have 7 listings so it feeds me back 14 urls, the 7 URLs each with a duplicate.

(我有7个列表,因此它会反馈14个URL,每个7个URL都有重复。)

I've found how others do it with manually imported numbers using list(set()) but haven't had any luck with urls.

(我发现其他人如何使用list(set())用手动导入的数字来做到这一点,但网址却没有运气。)

I need to be able to get a list of just the 7 URL's so that way the later parts of my script can use it to access each individual URL one after another.

(我需要能够仅获得7个URL的列表,以便脚本的后续部分可以使用它依次访问每个单独的URL。)

And I thinking need a single list not several lists for that to work?

(我想只需要一个列表,而不是几个列表就可以了?)

Any ideas how I could go about doing this?

(有什么想法我可以去做吗?)

Thanks so much in advance for any advice!

(非常感谢您的任何建议!)

  ask by Michael translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...