Is there any Python developer here?

Hi everybody! :slight_smile:

I got interview project to do and I could use some help because I got stuck. I’m super new to Python and I never learned it before I started this task. It’s my second attempt as in February I faild to do it but people at that company are nice and they let me try again recently.

So my task is to write a web scraping script in Python which takes content of their blog and counts word by author, saves it in PostgresSQL and return those stats by Django REST API. I wrote the script and it does save everything in database. What I got stuck is the API itself.

Is it possible to run command line script as a response to http request? I have to do it by Monday and I’m running out of time so my stress level is super high :frowning:


1 Like

Check this out

Tried to get that code to work, it doesn’t work in it’s original form. :confused:

What sort of issue are you having? I can get it to work without changing anything.

I’ve not done Django, but what you need sounds achievable with flask and SQL Alchemy

You already have your database. Write a data model for abstraction with SQL Alchemy, connect the database, and query with SQLAlchemy, use flask to retrieve request and return a jsonified query result.

It doesn’t have all the Django features, but for a prototype, it should be pretty quick and painless

here’s something similar to what I described


Thank you @psychometry, I will try it soon and I will let you know how it went :slight_smile:

you can use drf(django rest framework -django ) as well easy to learn .

I think it’s better to learn from the web. You have a lot of information and it’s easier then reading a book. As a new to python I recommend you to learn how program as much as you can because programming without enough knowledge can harm you and lead to errors. Of course you can always use some programs such as checkmarx and others to help you but it’s still recommended to do it on your own.
Anyway, good luck!

Seconding the Flask recommendation – it’s lightweight and you can pretty easily set up routes to return data with SQLAlchemy as @psychometry noted. The actual python you’d need to know to do build that is very simple, and there’s tons of examples out there. Good luck!

Thanks guys for help, I send the task but I haven’t got any feedback so I guess they didn’t like my script. :frowning: