-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#Firebase Imports | ||
import firebase_admin | ||
from firebase_admin import credentials | ||
from firebase_admin import db | ||
|
||
cred = credentials.Certificate("/firebase-admin-key.json") | ||
|
||
|
||
print("initilising firebase app") | ||
|
||
#Initilising Database | ||
firebase_admin.initialize_app(cred, { | ||
'databaseURL' : 'https://<project-id>-<database-instance>.firebaseio.com/' | ||
}) | ||
|
||
# Initilising Database 2 | ||
app2 = firebase_admin.initialize_app(cred, { | ||
'databaseURL': 'https://<project-id>-<database-instance>.firebaseio.com/' | ||
}, name='app2') | ||
|
||
|
||
|
||
# Fetch Data from firebase | ||
def fetch_data_firebase(path): | ||
ref=db.reference('Users',app2).child(path) | ||
data=ref.get() | ||
print(data) | ||
print("Succesfully fetched data from firebase ") | ||
|
||
# Update Data from firebase | ||
def update_data_firebase(path,data): | ||
ref=db.reference('Users',app2).child(path) | ||
ref.set(data) | ||
print("Succesfully updated the data in firebase") | ||
|
||
# Delete Data from firebase | ||
def delete_data_firebase(path): | ||
ref=db.reference('Users',app2).child(path) | ||
ref.delete() | ||
print("Succesfully deleted the data from firebase") | ||
|
||
# Main Function | ||
def main(): | ||
fetch_data_firebase("Registered") | ||
|
||
data_to_update={"my-key": "value"} | ||
update_data_firebase("Updated",data_to_update) | ||
|
||
delete_data_firebase("UnRegistered") | ||
|
||
#Main program | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#Firebase Imports | ||
import firebase_admin | ||
from firebase_admin import credentials | ||
from firebase_admin import db | ||
|
||
cred = credentials.Certificate("/firebase-admin-key.json") | ||
|
||
|
||
print("initilising firebase app") | ||
|
||
#Initilising Database | ||
firebase_admin.initialize_app(cred, { | ||
'databaseURL' : 'https://<project-id>-<database-instance>.firebaseio.com/' | ||
}) | ||
|
||
# Initilising Database 2 | ||
app2 = firebase_admin.initialize_app(cred, { | ||
'databaseURL': 'https://<project-id>-<database-instance>.firebaseio.com/' | ||
}, name='app2') | ||
|
||
|
||
|
||
# Fetch Data from firebase | ||
def fetch_data_firebase(path): | ||
ref=db.reference('Users',app2).child(path) | ||
data=ref.get() | ||
print(data) | ||
print("Succesfully fetched data from firebase ") | ||
|
||
# Update Data from firebase | ||
def update_data_firebase(path,data): | ||
ref=db.reference('Users',app2).child(path) | ||
ref.set(data) | ||
print("Succesfully updated the data in firebase") | ||
|
||
# Delete Data from firebase | ||
def delete_data_firebase(path): | ||
ref=db.reference('Users',app2).child(path) | ||
ref.delete() | ||
print("Succesfully deleted the data from firebase") | ||
|
||
# Main Function | ||
def main(): | ||
fetch_data_firebase("Registered") | ||
|
||
data_to_update={"my-key": "value"} | ||
update_data_firebase("Updated",data_to_update) | ||
|
||
delete_data_firebase("UnRegistered") | ||
|
||
#Main program | ||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Fetching get request by setting User Agent parameter | ||
|
||
### POST METHOD | ||
- To add json data into some web api endpoint | ||
|
||
```python | ||
|
||
``` | ||
|
||
### Disclaimer | ||
- Please use this scripts for educational purpose only | ||
- Read the web scrapping policy of the website before scrapping it | ||
- You can be subjected to legal formalities when you violate their policies | ||
- Use web scraping for educational purpose only | ||
- Scrap with websites which do allow web scrapping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#For invoking http requests | ||
import requests | ||
|
||
#Json Parsing | ||
import json | ||
|
||
|
||
def main(): | ||
#For Testing | ||
url='https://w' | ||
|
||
#This website prevents normal Traffic, unlesss you specify the user agent, the server won't response | ||
resp = requests.put(url,headers=headers) | ||
print("Done..") | ||
print(resp) | ||
data = resp.json() | ||
print(data) | ||
|
||
#Main program | ||
if __name__ == '__main__': | ||
main() |