0

First of all, I am new to python. I am trying to make a web crawler that keeps keeps checking a particular website until it finds a specific tv series keywords available.

I have gone through the other answers many times by now, but nothing works for me. I am unable to install pygame as suggested here:- Playing mp3 song on python

Tried importing the the webbrowser, installing vlc module from git, things dont work out.

Can someone just give me a simple detailed guide to do this?

Community
  • 1
  • 1
Saket
  • 41
  • 1
  • 6

2 Answers2

2

Assuming the song 'your_song.mp3' is stored in your computer in the directory '/Users/', you can open the song from your python program doing this:

import subprocess 

subprocess.Popen(['open','/Users/your_song.mp3'])

Note: the previous code will work on OS X. For windows, type instead:

subprocess.Popen(['start','/Users/your_song.mp3'],shell=True)
simon.sim
  • 149
  • 4
0

Assuming you are on a *nix based system, here is a simple example using the python standard library.

>>> import urllib.request
>>> import subprocess
>>> url = 'http://example.com/'
>>> req = urllib.request.Request(url)
>>> data = urllib.request.urlopen(req)
>>> data
<http.client.HTTPResponse object at 0x7f483018be80>
>>> html_data = data.read()
>>> ## replace it with your logic
>>> your_case_here = True
>>> if your_case_here:
...   subprocess.run(["gnome-open", "/path/to/mo3_file/hello.mp3", "/dev/null"], stdout=subprocess.PIPE)
... else:
...   pass
>>>
Tasdik Rahman
  • 2,160
  • 1
  • 25
  • 37