Skip to content

Commit

Permalink
Ganti package untuk bypass Cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
wildangunawan committed Mar 27, 2021
1 parent 56f96ba commit 119d480
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
11 changes: 6 additions & 5 deletions get-data-harian-emiten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import urllib3, json
import cfscrape, json
import pandas as pd
from time import sleep

Expand All @@ -15,7 +15,7 @@
kode_lq45 = lq45['code'].values

# http client
http = urllib3.PoolManager()
http = cfscrape.create_scraper()

for code in kode_emiten:
# link
Expand All @@ -26,9 +26,10 @@
# request whenever failed
while True:
try:
result = http.request('GET', link)
result = http.request('GET', link)
result = json.loads(result.data.decode('utf-8'))
# send request
result = http.get(link).text
result = http.get(link).text
result = json.loads(result)

# success, we stop the while loop
break
Expand Down
9 changes: 5 additions & 4 deletions get-data-tahunan-emiten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import urllib3, json
import cfscrape, json
import pandas as pd
from time import sleep

Expand All @@ -16,7 +16,7 @@
lq45 = lq45['code'].values

# http client
http = urllib3.PoolManager()
http = cfscrape.create_scraper()

for code in emiten:
# link
Expand All @@ -27,8 +27,9 @@
# request whenever failed
while True:
try:
result = http.request('GET', link)
result = json.loads(result.data.decode('utf-8'))
# send request
result = http.get(link).text
result = json.loads(result)

# success, we brake the while loop
break
Expand Down
8 changes: 4 additions & 4 deletions get-list-emiten.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import urllib3, json
import cfscrape, json
import pandas as pd

# mulai dari 0
Expand Down Expand Up @@ -26,15 +26,15 @@
lq45_listingBoard = []

# http client
http = urllib3.PoolManager()
http = cfscrape.create_scraper()

while True:
# buat link
link = f"https://idx.co.id/umbraco/Surface/StockData/GetSecuritiesStock?code=&sector=&board=&start={start}&length={length}"

# send request
result = http.request('GET', link)
result = json.loads(result.data.decode('utf-8'))
result = http.get(link).text
result = json.loads(result)

# result empty?
# kalo iya, berarti daftar
Expand Down
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
urllib3
pandas
kaggle
cfscrape
pandas

0 comments on commit 119d480

Please sign in to comment.