質問編集履歴
2
例として問題なく動いているURLの階層を問題のURLのサブドメインと揃えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
パーミッションは755にしてあります。
|
13
13
|
|
14
14
|
例として問題なく動いているURL、
|
15
|
-
https://mac-in.net/
|
15
|
+
https://appli.mac-in.net/youtube-support_registration_square/custom_url_YSC.py
|
16
16
|
|
17
17
|
### 該当のソースコード
|
18
18
|
|
1
意図通り動いている方のソースコードを貼り忘れてました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,35 @@
|
|
51
51
|
サーバー:ロリポップ
|
52
52
|
端末:macOS Mojave 10.14.6
|
53
53
|
|
54
|
+
上記、意図通りに動いている例のcustom_url_YSC.pyのソースコード
|
55
|
+
```Python
|
56
|
+
#!/usr/local/bin/python3
|
57
|
+
# coding:utf-8
|
58
|
+
|
59
|
+
import os
|
60
|
+
import sys
|
61
|
+
import cgi
|
62
|
+
from ast import keyword
|
63
|
+
import re
|
64
|
+
sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../vendor'))
|
65
|
+
import requests
|
66
|
+
from bs4 import BeautifulSoup
|
67
|
+
|
68
|
+
print('Content-type: text/html\n')
|
69
|
+
print('Status: 200 OK')
|
70
|
+
#print(os.path.join(os.path.abspath(os.path.dirname(__file__))))
|
71
|
+
|
72
|
+
channelID_len = 24 #チャンネルIDの長さ
|
73
|
+
keyWord = '"browseId":"'
|
74
|
+
url = sys.stdin.readline() #JavaScriptから受け取る
|
75
|
+
#url = 'https://www.youtube.com/c/TsuriHamTVAnother%E9%87%A3%E3%82%8A%E3%83%8F%E3%83%A0TVA'
|
76
|
+
# seikai = 'UC_zCH7-RTmaFEvSWoE6z5QA'
|
77
|
+
|
78
|
+
res = requests.get(url)
|
79
|
+
soup = BeautifulSoup(res.text, "html.parser")
|
80
|
+
mojiretsu = str(soup)
|
81
|
+
keyPosition = mojiretsu.find(keyWord)
|
82
|
+
channelID = mojiretsu[keyPosition + len(keyWord) : keyPosition + len(keyWord) + channelID_len]
|
83
|
+
|
84
|
+
print('data:' + channelID) #JavaScriptに渡す
|
85
|
+
```
|