Python Forum
Python Export Question Below
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Export Question Below
#1
Any ideas on how to put the printed results in a CSV, JSON, or Excel format/file?

import requests
from parsel import Selector
 
#GET request from the website
response = requests.get('https://www.youtube.com/')
selector = Selector(response.text)
hreflinks = selector.xpath('//a/@href').getall()
imagelinks = selector.xpath('//img/@src').getall()
 
print(hreflinks)
print(imagelinks)
Reply
#2
I'm curious why parsel?
What does it offer over selenium?
You should be able to write hreflinks and imagelinks directly to a file
just open a file and write to file instead of printing.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Export Python output to Excel skyline1397 1 2,061 Jun-26-2022, 05:10 AM
Last Post: skyline1397
  Yahoo_fin question: how does one export all stock tickers to a csv file detlefschmitt 9 8,799 Feb-12-2021, 07:46 AM
Last Post: detlefschmitt
  How to export from Python to Excel? jpy 4 6,377 Dec-23-2020, 03:26 PM
Last Post: jpy
  Skeleton file export error Python Code pepapoha 4 3,521 Nov-17-2020, 02:06 AM
Last Post: pepapoha
  CGI in python, problem with pandas, plotly.express and export html HK2432 0 2,137 Jan-19-2020, 01:30 PM
Last Post: HK2432
  python export to csv writes extra line between rows jahjahcity 4 10,379 Jul-25-2018, 01:36 AM
Last Post: jahjahcity
  [PYTHON EXPORT SQL TO .txt file] PYTHONDUDE 9 24,317 Feb-21-2018, 08:54 PM
Last Post: nilamo
  Python 3 mysql export to csv elliott0184 3 15,381 Feb-23-2017, 03:18 PM
Last Post: joe_anonimist
  How to export map output from Python medurisu2002 1 4,335 Dec-18-2016, 12:56 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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