<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to connect to external lookup using Python script? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-connect-to-external-lookup-using-Python-script/m-p/307385#M57886</link>
    <description>&lt;P&gt;I know this is a bit old but here's how I  authenticate with Basic HTTP Auth:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests
from requests.auth import HTTPBasicAuth

username = "&amp;lt;user&amp;gt;"
apikey = "&amp;lt;pass&amp;gt;"
apiurl = "&amp;lt;theurlyouconnectto&amp;gt;"

with requests.Session() as s:
    s.auth = (username,apikey)
    r = s.get(apiurl)    
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 17 Jan 2019 20:16:06 GMT</pubDate>
    <dc:creator>jpass</dc:creator>
    <dc:date>2019-01-17T20:16:06Z</dc:date>
    <item>
      <title>How to connect to external lookup using Python script?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-connect-to-external-lookup-using-Python-script/m-p/307384#M57885</link>
      <description>&lt;P&gt;We were using below script to connect and download csv and store it in folder. But now website has changed and it asks for the username and password. Can somebody suggests any required changes where we can connect to URL, Authenticate with username and password, and download the file?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import os

import urllib2

response = urllib2.urlopen('URL')

data = response.read()

filename = os.path.join(os.environ['SPLUNK_HOME'], 'etc', 'apps', 'SPLAPP', 'lookups', "Splunk_Monitored_Hosts.csv")

file_ = open(filename, 'w')

file_.write(data)
#file_.close()
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Mar 2018 12:53:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-connect-to-external-lookup-using-Python-script/m-p/307384#M57885</guid>
      <dc:creator>nnimbe1</dc:creator>
      <dc:date>2018-03-29T12:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to connect to external lookup using Python script?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-connect-to-external-lookup-using-Python-script/m-p/307385#M57886</link>
      <description>&lt;P&gt;I know this is a bit old but here's how I  authenticate with Basic HTTP Auth:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests
from requests.auth import HTTPBasicAuth

username = "&amp;lt;user&amp;gt;"
apikey = "&amp;lt;pass&amp;gt;"
apiurl = "&amp;lt;theurlyouconnectto&amp;gt;"

with requests.Session() as s:
    s.auth = (username,apikey)
    r = s.get(apiurl)    
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Jan 2019 20:16:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-connect-to-external-lookup-using-Python-script/m-p/307385#M57886</guid>
      <dc:creator>jpass</dc:creator>
      <dc:date>2019-01-17T20:16:06Z</dc:date>
    </item>
  </channel>
</rss>

