<?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 pyspark: How to run selenium in UDF in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/pyspark-how-to-run-selenium-in-udf/m-p/17468#M11489</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am building a webscraper to get prices of certain EAN's from the amazon website. Therefore I use selenium to get the product links. I wrote te following function to get the productlinks based on a EAN:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;def getProductLinkAmazonPY(EAN):
  startURL = 'https://www.amazon.nl'
  driver.get(startURL)
  element = driver.find_element_by_id('twotabsearchtextbox')
  element.send_keys(EAN)
  element.send_keys(Keys.RETURN);
  productPage = [elem.get_attribute("href") for elem in driver.find_elements_by_xpath("//*[@class='a-link-normal a-text-normal']")] 
  if productPage != []:
    productPage = productPage[0]
    return[productPage, EAN]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does somebody know how to run this function parallel in pyspark using an UDF?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jul 2021 07:10:48 GMT</pubDate>
    <dc:creator>DievanB</dc:creator>
    <dc:date>2021-07-22T07:10:48Z</dc:date>
    <item>
      <title>pyspark: How to run selenium in UDF</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-how-to-run-selenium-in-udf/m-p/17468#M11489</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am building a webscraper to get prices of certain EAN's from the amazon website. Therefore I use selenium to get the product links. I wrote te following function to get the productlinks based on a EAN:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;def getProductLinkAmazonPY(EAN):
  startURL = 'https://www.amazon.nl'
  driver.get(startURL)
  element = driver.find_element_by_id('twotabsearchtextbox')
  element.send_keys(EAN)
  element.send_keys(Keys.RETURN);
  productPage = [elem.get_attribute("href") for elem in driver.find_elements_by_xpath("//*[@class='a-link-normal a-text-normal']")] 
  if productPage != []:
    productPage = productPage[0]
    return[productPage, EAN]&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Does somebody know how to run this function parallel in pyspark using an UDF?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jul 2021 07:10:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-how-to-run-selenium-in-udf/m-p/17468#M11489</guid>
      <dc:creator>DievanB</dc:creator>
      <dc:date>2021-07-22T07:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: pyspark: How to run selenium in UDF</title>
      <link>https://community.databricks.com/t5/data-engineering/pyspark-how-to-run-selenium-in-udf/m-p/17469#M11490</link>
      <description>&lt;P&gt;UDF functions are serialized and then executed on executors. I don't think it will be possible with Selenium.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Nov 2021 17:03:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/pyspark-how-to-run-selenium-in-udf/m-p/17469#M11490</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2021-11-27T17:03:16Z</dc:date>
    </item>
  </channel>
</rss>

