Edit Your Comment
Community outlook data scraping
Jan 28, 2021 at 07:34
เป็นสมาชิกตั้งแต่ Jan 19, 2021
7 โพสต์
Hi,
I am trying to get community outlook data, sending minute by minute requests, using JSON. It works once and I am getting an error in the next minute's try. Here are the code and the error, has someone had a similar problem? or any idea to fix it?
import requests
import json
Login = 'https://www.myfxbook.com/api/login.json?email=email&password=password'
Login_response = requests.get(Login, verify = False)
Login_data = Login_response.json()
session_id = Login_data['session']
Outlook='https://www.myfxbook.com/api/get-community-outlook.json?session=' + session_id
Outlook_response = requests.get(Outlook, verify = False)
Outlook_data = Outlook_response.json()['symbols']
Error:
Outlook_data = Outlook_response.json()['symbols']
File 'C:\Python\lib\site-packages\requests\models.py', line 900, in json
return complexjson.loads(self.text, **kwargs)
File 'C:\Python\lib\json\__init__.py', line 357, in loads
return _default_decoder.decode(s)
File 'C:\Python\lib\json\decoder.py', line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File 'C:\Python\lib\json\decoder.py', line 355, in raw_decode
raise JSONDecodeError('Expecting value', s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I am trying to get community outlook data, sending minute by minute requests, using JSON. It works once and I am getting an error in the next minute's try. Here are the code and the error, has someone had a similar problem? or any idea to fix it?
import requests
import json
Login = 'https://www.myfxbook.com/api/login.json?email=email&password=password'
Login_response = requests.get(Login, verify = False)
Login_data = Login_response.json()
session_id = Login_data['session']
Outlook='https://www.myfxbook.com/api/get-community-outlook.json?session=' + session_id
Outlook_response = requests.get(Outlook, verify = False)
Outlook_data = Outlook_response.json()['symbols']
Error:
Outlook_data = Outlook_response.json()['symbols']
File 'C:\Python\lib\site-packages\requests\models.py', line 900, in json
return complexjson.loads(self.text, **kwargs)
File 'C:\Python\lib\json\__init__.py', line 357, in loads
return _default_decoder.decode(s)
File 'C:\Python\lib\json\decoder.py', line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File 'C:\Python\lib\json\decoder.py', line 355, in raw_decode
raise JSONDecodeError('Expecting value', s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
เป็นสมาชิกตั้งแต่ Jan 17, 2021
29 โพสต์
Mar 03, 2021 at 12:50
เป็นสมาชิกตั้งแต่ Jan 19, 2021
7 โพสต์
Np, for avoiding the mentioned error you need to run the first part once (till the sixth line), and repeat only the second part every 15 minutes or more, using a loop or any other technic. Free accounts are not able to collect data in less than 15 minutes time frames. Also, replace the email and password with your account information and log out at the end.
Aug 15, 2021 at 18:35
(แก้ไขแล้ว Aug 15, 2021 at 19:06)
เป็นสมาชิกตั้งแต่ Aug 14, 2021
1 โพสต์
The response should be this:
{
"error": false,
"message": "",
"symbols": [
{
"name": "EURUSD",
"shortPercentage": 55,
"longPercentage": 44,
"shortVolume": 1142.58,
"longVolume": 905.47,
"longPositions": 2932,
"shortPositions": 3888,
"totalPositions": 2048,
"avgShortPrice":1.3808,
"avgLongPrice":1.4097
}
],
"general": {
"demoAccountsPercentage": 43,
"realAccountsPercentage": 56,
"profitablePercentage": 54,
"nonProfitablePercentage": 45,
"fundsWon": "6,819,251.63",
"fundsLost": "-8,740,646.15",
"averageDeposit": "21,740.16",
"averageAccountProfit": "4,127.88",
"averageAccountLoss": "-5,290.95",
"totalFunds": "35,914,737.56"
}
}
{
"error": false,
"message": "",
"symbols": [
{
"name": "EURUSD",
"shortPercentage": 55,
"longPercentage": 44,
"shortVolume": 1142.58,
"longVolume": 905.47,
"longPositions": 2932,
"shortPositions": 3888,
"totalPositions": 2048,
"avgShortPrice":1.3808,
"avgLongPrice":1.4097
}
],
"general": {
"demoAccountsPercentage": 43,
"realAccountsPercentage": 56,
"profitablePercentage": 54,
"nonProfitablePercentage": 45,
"fundsWon": "6,819,251.63",
"fundsLost": "-8,740,646.15",
"averageDeposit": "21,740.16",
"averageAccountProfit": "4,127.88",
"averageAccountLoss": "-5,290.95",
"totalFunds": "35,914,737.56"
}
}

*การใช้งานเชิงพาณิชย์และสแปมจะไม่ได้รับการยอมรับ และอาจส่งผลให้บัญชีถูกยกเลิก
เคล็ดลับ: การโพสต์รูปภาพ/youtube url จะฝังลงในโพสต์ของคุณโดยอัตโนมัติ!
เคล็ดลับ: พิมพ์เครื่องหมาย @ เพื่อป้อนชื่อผู้ใช้ที่เข้าร่วมการสนทนานี้โดยอัตโนมัติ