Python错误IOError:[Errno 2]没有这样的文件或目录:

时间:2015-03-16 18:36:15

标签: python errno ioerror

是我的剧本

    from bs4 import BeautifulSoup
import requests
import sys
import os


givenURL = raw_input("Entrer votre liens ")


headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

# initialize session
session = requests.Session()

# getting playlist
response = session.get(givenURL, headers=headers)
soup = BeautifulSoup(response.content)
playlist = soup.find('a', {'data-playlist': True})['data-playlist']
oname = soup.find("title")
oname.text
print oname.text 

# getting list of videos
url = 'http://animedigitalnetwork.fr/index.php?option=com_vodvideo&view=playlist&format=raw'
response = session.post(url, data={
    'playlist': playlist,
    'season': '',
    'order': 'DESC'
}, headers=headers)

soup = BeautifulSoup(response.content)
path = os.path.join('Playlist', oname.text)
with open(path, 'w') as f:
    for video in soup.select('div.adn-video'):
        s = 'http://www.animedigitalnetwork.fr' + video.a.get('href')
        f.write(s + '\n')

# Read the file, and break after printing the first line.        
with open(path) as f:
    for line in f:
        print line.rstrip()
        break

我的脚本错误

Traceback (most recent call last):
  File "adnplay.py", line 33, in <module>
    with open(path, 'w') as f:
IOError: [Errno 2] No such file or directory: u'Playlist/Maria, Sorci\xe8re de gr\xe9, pucelle de force ! - VOSTFR'

我使用此脚本来检索网站的播放列表,我看不到如何修复脚本,因为我之前没有问题

我不明白错误

我真的需要你的帮助!

事先提前

0 个答案:

没有答案