Python Forum
convert set to a list type in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert set to a list type in python
#1
hi everyone so i am scraping amazon website, but having trouble to turn every absolute link into a list type? what am i doing wrong.. I am only getting one link as there are 16 links on one page.

from requests_html import HTMLSession

import time

import pandas as pd


s = HTMLSession()


r = s.get("https://www.amazon.in/s?k=oneplus&page=1")

r.html.render(sleep=1)



Everything = r.html.find("div.s-include-content-margin.s-border-bottom.s-latency-cf-section")


for e in Everything:

links = e.find("a.a-link-normal.a-text-normal")[0].absolute_links

t = list(links)

print("\n",t)
output

[Image: AZ1.png]
Reply
#2
Quote:convert set to a list type in python
>>> hh = {2, 4, 6, 8, 10}
>>> type(hh)
<class 'set'>
>>> hh = list(hh)
>>> type(hh)
<class 'list'>
firaki12345 likes this post
Reply
#3
cross-posted
https://stackoverflow.com/questions/6606...-list-type
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Q. Nested for statement in list type ives 3 1,650 Mar-14-2018, 07:30 AM
Last Post: Larz60+
  how to edit data frames and convert to a list(pandas, read_html()) ? donvirte 3 2,826 Feb-02-2018, 03:23 PM
Last Post: snippsat
  convert list compression to for loop Prince_Bhatia 5 3,129 Oct-09-2017, 10:42 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020