• 0

Casual print() to sys.stout - instead of storing the data on the machine


Question

hi there - good day

 

 

Casual print() to sys.stout - instead of storing the data on the machine  that is what i want to do. 

 

 

I am currently setting up ATOM and VSCode to work with python.

Whilst doing so i have some scripts that help me in the setup

 

the important thing is - i am currently figuging out where the editor store the results ..!?

 

 


 

import requests
from bs4 import BeautifulSoup
import pandas as pd


def Main(urls):
    with requests.Session() as req:
        allin = []
        for url in urls:
            r = req.get(url)
            soup = BeautifulSoup(r.content, 'html.parser')
            target = soup.find(
                "dl", class_="c-description-list c-description-list--striped")
            names = [item.text for item in target.findAll("dt")]
            names.append("url")
            data = [item.get_text(strip=True) for item in target.findAll("dd")]
            data.append(url)
            allin.append(data)
        df = pd.DataFrame(allin, columns=names)
        df.to_csv("data.csv", index=False)


urls = ['https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/4722/',
        'https://www2.daad.de/deutschland/studienangebote/international-programmes/en/detail/6318/']
Main(urls)

 

 

 

Besides this : besides the question of storge i also can try to print the results on Teminal

 

yes i do not want to write this into a file - i want to print this out on terminal

so i guess that i need to use sys.stout...

 

- i have learned that Casual print() should do it in case to run like so i want to pipe output on the terminal

 

 

import sys

sys.stdout = open(' data.csv(', 'w')

and then in my terminal window do


tail -f /data.csv

 

is this correct!?

 

but the issue is that i do not know where ATOM does store this !?

neither where VsCode does store the results.

 

look forward to heaer from you

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.