Skip to content
Snippets Groups Projects
Commit d49d89fd authored by Agustín Céspedes's avatar Agustín Céspedes
Browse files

add_advertisement function

parent 617568df
No related branches found
No related tags found
2 merge requests!2PROD1.0,!1PROD 0.1
......@@ -3,3 +3,4 @@ django
psycopg2-binary
django_cron
djangorestframework
requests
\ No newline at end of file
print("Scrapers")
import requests
def add_advertisement(company_id, source_id, market_id, text_content, url, reach=None):
endpoint = 'http://localhost:8000/dashboard/create_ad/'
data = {
'company': company_id,
'source': source_id,
'market': market_id,
'text_content': text_content,
'url': url,
}
if reach is not None:
data['reach'] = reach
response = requests.post(endpoint, json=data, auth=('agustin', '123'))
if response.status_code == 200:
print("Advertisement created successfully.")
print("Response:", response.json())
else:
print("Failed to create advertisement.")
print("Response:", response.json())
add_advertisement(1, 1, 1, "hola que tal", "httgp://www.hola.com")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment