<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Python on Research Tool</title>
    <link>/tags/python/</link>
    <description>Recent content in Python on Research Tool</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <managingEditor>cahoover@gmail.com (Christopher Hoover)</managingEditor>
    <webMaster>cahoover@gmail.com (Christopher Hoover)</webMaster>
    <lastBuildDate>Wed, 19 Feb 2025 00:00:00 +0000</lastBuildDate><atom:link href="/tags/python/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Boolean Indexing Using Pandas</title>
      <link>/posts/boolean-indexing-using-pandas/</link>
      <pubDate>Wed, 19 Feb 2025 00:00:00 +0000</pubDate>
      <author>cahoover@gmail.com (Christopher Hoover)</author>
      <guid>/posts/boolean-indexing-using-pandas/</guid>
      <description>&lt;p&gt;A boolean operation returns only True or False, and can only be performed against a series. The process of boolean indexing involves two steps: first, evaluate the series to identify true/false values, then filter the dataframe based on results.&lt;/p&gt;
&lt;h2 id=&#34;operators&#34;&gt;Operators&lt;/h2&gt;
&lt;p&gt;Here are the standard boolean operators:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;== a&lt;/code&gt; : Equality comparison&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~a&lt;/code&gt; : Negation (NOT)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;gt; b&lt;/code&gt; : Greater than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;lt; b&lt;/code&gt; : Less than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;amp; b&lt;/code&gt; : AND operator&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a | b&lt;/code&gt; : OR operator&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;filtering-a-dataframe&#34;&gt;Filtering a Dataframe&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s demonstrate filtering using a dataset. First, create an evaluation series:&lt;/p&gt;</description>
      <content>&lt;p&gt;A boolean operation returns only True or False, and can only be performed against a series. The process of boolean indexing involves two steps: first, evaluate the series to identify true/false values, then filter the dataframe based on results.&lt;/p&gt;
&lt;h2 id=&#34;operators&#34;&gt;Operators&lt;/h2&gt;
&lt;p&gt;Here are the standard boolean operators:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;== a&lt;/code&gt; : Equality comparison&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~a&lt;/code&gt; : Negation (NOT)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;gt; b&lt;/code&gt; : Greater than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;lt; b&lt;/code&gt; : Less than&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a &amp;amp; b&lt;/code&gt; : AND operator&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a | b&lt;/code&gt; : OR operator&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;filtering-a-dataframe&#34;&gt;Filtering a Dataframe&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s demonstrate filtering using a dataset. First, create an evaluation series:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;evaluation &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; df[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;number&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This identifies entries meeting the condition. Next, apply the filter to return matching rows:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;df[evaluation]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;selecting-specific-data&#34;&gt;Selecting Specific Data&lt;/h2&gt;
&lt;p&gt;You can combine conditions for more advanced filtering.&lt;/p&gt;
&lt;p&gt;Combining OR conditions across country values:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;df[(df[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;country&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;USA&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;|&lt;/span&gt; (df[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;country&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Canada&amp;#39;&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Using negation with AND to exclude specific criteria while filtering by sector:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;df[(&lt;span style=&#34;color:#f92672&#34;&gt;~&lt;/span&gt;df[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;country&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;USA&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt; (df[&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;sector&amp;#39;&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Technology&amp;#39;&lt;/span&gt;)]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Boolean indexing enables data exploration by creating filtered datasets based on conditional logic applied to dataframe columns.&lt;/p&gt;
</content>
    </item>
    
    <item>
      <title>Getting Started with the Google Ads API Using Python</title>
      <link>/posts/getting-started-with-the-google-ads-api-using-python-3/</link>
      <pubDate>Mon, 19 Feb 2024 00:00:00 +0000</pubDate>
      <author>cahoover@gmail.com (Christopher Hoover)</author>
      <guid>/posts/getting-started-with-the-google-ads-api-using-python-3/</guid>
      <description>&lt;p&gt;Launching with the Google Ads API involves multiple steps that can feel overwhelming. This guide walks through the entire process comprehensively to help you succeed.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the complete roadmap:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Establish a Google Ads manager account (if you don&amp;rsquo;t have one)&lt;/li&gt;
&lt;li&gt;Request a developer token through your manager account&lt;/li&gt;
&lt;li&gt;Set up a Google Ads manager TEST account&lt;/li&gt;
&lt;li&gt;Set up a Google Ads regular TEST account&lt;/li&gt;
&lt;li&gt;Build sample campaigns in your regular test account&lt;/li&gt;
&lt;li&gt;Establish a Google Cloud project&lt;/li&gt;
&lt;li&gt;Activate the Google Ads API within your Cloud Project&lt;/li&gt;
&lt;li&gt;Obtain OAUTH credentials from Cloud Project&lt;/li&gt;
&lt;li&gt;Export credentials as JSON format&lt;/li&gt;
&lt;li&gt;Download the Google Ads API library via pip&lt;/li&gt;
&lt;li&gt;Clone the Google Ads API GitHub repository&lt;/li&gt;
&lt;li&gt;Execute a credential script to obtain a refresh token&lt;/li&gt;
&lt;li&gt;Transfer a YAML configuration file to your home directory&lt;/li&gt;
&lt;li&gt;Populate the YAML with your OAUTH credentials, developer token, and refresh token&lt;/li&gt;
&lt;li&gt;Execute your inaugural API request&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;get-a-google-ads-manager-account&#34;&gt;Get a Google Ads Manager Account&lt;/h2&gt;
&lt;p&gt;Two distinct Google Ads account types exist:&lt;/p&gt;</description>
      <content>&lt;p&gt;Launching with the Google Ads API involves multiple steps that can feel overwhelming. This guide walks through the entire process comprehensively to help you succeed.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the complete roadmap:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Establish a Google Ads manager account (if you don&amp;rsquo;t have one)&lt;/li&gt;
&lt;li&gt;Request a developer token through your manager account&lt;/li&gt;
&lt;li&gt;Set up a Google Ads manager TEST account&lt;/li&gt;
&lt;li&gt;Set up a Google Ads regular TEST account&lt;/li&gt;
&lt;li&gt;Build sample campaigns in your regular test account&lt;/li&gt;
&lt;li&gt;Establish a Google Cloud project&lt;/li&gt;
&lt;li&gt;Activate the Google Ads API within your Cloud Project&lt;/li&gt;
&lt;li&gt;Obtain OAUTH credentials from Cloud Project&lt;/li&gt;
&lt;li&gt;Export credentials as JSON format&lt;/li&gt;
&lt;li&gt;Download the Google Ads API library via pip&lt;/li&gt;
&lt;li&gt;Clone the Google Ads API GitHub repository&lt;/li&gt;
&lt;li&gt;Execute a credential script to obtain a refresh token&lt;/li&gt;
&lt;li&gt;Transfer a YAML configuration file to your home directory&lt;/li&gt;
&lt;li&gt;Populate the YAML with your OAUTH credentials, developer token, and refresh token&lt;/li&gt;
&lt;li&gt;Execute your inaugural API request&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;get-a-google-ads-manager-account&#34;&gt;Get a Google Ads Manager Account&lt;/h2&gt;
&lt;p&gt;Two distinct Google Ads account types exist:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Regular account:&lt;/strong&gt; This functions as an operational account where you develop and execute advertising campaigns.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Manager account:&lt;/strong&gt; This serves as a parent account for overseeing multiple regular accounts.&lt;/p&gt;
&lt;p&gt;Manager accounts cannot run advertisements directly — they exist solely for supervision purposes. Marketing agencies, for instance, typically maintain two accounts: one regular account for their own promotions and one manager account for client management.&lt;/p&gt;
&lt;p&gt;Without an existing manager account, establish one by visiting the &lt;a href=&#34;https://ads.google.com/home/tools/manager-accounts/&#34;&gt;Google Ads Manager Homepage&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;get-a-developer-token&#34;&gt;Get a Developer Token&lt;/h2&gt;
&lt;p&gt;A developer token represents your first required credential for API access. Obtaining one is straightforward. Access your Manager account and navigate to &lt;strong&gt;TOOLS &amp;amp; SETTINGS &amp;gt; SETUP &amp;gt; API Center&lt;/strong&gt;. (This option appears exclusively in Manager Accounts.)&lt;/p&gt;
&lt;p&gt;Complete the application form, acknowledge the terms and conditions, and submit. Provide an active email address you monitor regularly. Once approved, your token displays as an alphanumeric string in the API Center.&lt;/p&gt;
&lt;p&gt;Save this token in a readily accessible location, such as a text document.&lt;/p&gt;
&lt;h2 id=&#34;set-up-a-google-ads-test-manager-account&#34;&gt;Set Up a Google Ads TEST Manager Account&lt;/h2&gt;
&lt;p&gt;Initially, Google restricts API access to production accounts. For API development, you require a test environment. Create a second manager account by revisiting the &lt;a href=&#34;https://ads.google.com/home/tools/manager-accounts/&#34;&gt;Google Ads Manager Homepage&lt;/a&gt; and establishing another MCC using your existing email address.&lt;/p&gt;
&lt;p&gt;This creates a test account, identifiable by the red &amp;ldquo;test account&amp;rdquo; badge displayed prominently.&lt;/p&gt;
&lt;h2 id=&#34;set-up-a-google-ads-test-regular-account&#34;&gt;Set Up a Google Ads TEST Regular Account&lt;/h2&gt;
&lt;p&gt;The documentation references generating test accounts &amp;ldquo;using the Google UI,&amp;rdquo; which can confuse newcomers. The actual process involves clicking &lt;strong&gt;ACCOUNTS&lt;/strong&gt; in the left navigation menu, then selecting the &amp;ldquo;+&amp;rdquo; link.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;IMPORTANT NOTE:&lt;/strong&gt; The interface will display a complaint about account usability, present a billing warning, and appear unresponsive.&lt;/p&gt;
&lt;p&gt;Community forums overflow with users reporting that test account creation appears unsuccessful. Google acknowledges this issue and promises resolution, though if you experience this, understand that your account exists — it&amp;rsquo;s simply concealed. Access the filter option and select &amp;ldquo;Show hidden&amp;rdquo; to reveal it.&lt;/p&gt;
&lt;p&gt;Preserve the regular test account number in an accessible document.&lt;/p&gt;
&lt;h2 id=&#34;create-a-test-campaign-in-your-test-account&#34;&gt;Create a Test Campaign in Your Test Account&lt;/h2&gt;
&lt;p&gt;Enter your regular test account by selecting the corresponding link in your Manager account&amp;rsquo;s upper left corner.&lt;/p&gt;
&lt;p&gt;Generate a campaign by clicking &lt;strong&gt;campaigns&lt;/strong&gt; in the left sidebar and then the &amp;ldquo;+&amp;rdquo; link.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Important context about test accounts:&lt;/strong&gt; They contain no authentic data. Although you can create campaigns, they remain unpopulated with information, including simulated data for impressions, clicks, and budgets.&lt;/p&gt;
&lt;p&gt;Users anticipate test accounts resembling production environments with sample metrics — Facebook implements this approach, but Google does not. This disparity generates extensive community frustration documented across forums for years, yet Google has made no adjustments.&lt;/p&gt;
&lt;p&gt;Instead, Google recommends exporting production data as CSV format and simulating API retrieval from it.&lt;/p&gt;
&lt;h2 id=&#34;set-up-your-google-cloud-project&#34;&gt;Set Up Your Google Cloud Project&lt;/h2&gt;
&lt;p&gt;This process demands additional steps. API usage requires establishing a Google Cloud project, enabling the Google Ads API within it, and configuring authorization credentials.&lt;/p&gt;
&lt;p&gt;Begin by logging into &lt;a href=&#34;https://console.cloud.google.com/&#34;&gt;Google Cloud&lt;/a&gt; using your Manager Account credentials.&lt;/p&gt;
&lt;h3 id=&#34;create-a-google-cloud-project&#34;&gt;Create a Google Cloud Project&lt;/h3&gt;
&lt;p&gt;In the upper left area, select the project for use with the Google Ads API. Should you lack a project, select New Project.&lt;/p&gt;
&lt;p&gt;You may encounter billing setup prompts (particularly if you haven&amp;rsquo;t previously entered payment information). Complete this process. Unless you execute thousands of daily API calls or utilize substantial additional cloud resources, billing concerns are minimal.&lt;/p&gt;
&lt;h3 id=&#34;enable-the-google-ads-api-in-your-project&#34;&gt;Enable the Google Ads API in Your Project&lt;/h3&gt;
&lt;p&gt;Verify your project selection, then select &lt;strong&gt;APIs and Services&lt;/strong&gt; from the left sidebar.&lt;/p&gt;
&lt;p&gt;Select the &lt;strong&gt;+ API and Services&lt;/strong&gt; link at the page&amp;rsquo;s top.&lt;/p&gt;
&lt;p&gt;Locate Google Ads in the search results. Upon finding it, select it and click &lt;strong&gt;ENABLE&lt;/strong&gt;. When asked about application category, choose &lt;strong&gt;Installed App&lt;/strong&gt; (select Web App if constructing a multi-user platform for account access — unlikely for beginners).&lt;/p&gt;
&lt;h3 id=&#34;create-your-credentials&#34;&gt;Create Your Credentials&lt;/h3&gt;
&lt;p&gt;Return to &lt;strong&gt;APIs and Services&lt;/strong&gt;, then select &lt;strong&gt;credentials&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On the Credentials interface, select &lt;strong&gt;CREATE CREDENTIALS&lt;/strong&gt;, then choose &lt;strong&gt;OAuth client ID&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Select &lt;strong&gt;&amp;ldquo;Other&amp;rdquo;&lt;/strong&gt; as the application type.&lt;/p&gt;
&lt;p&gt;Two credentials display: a client ID and corresponding secret. Store both values securely in a text document.&lt;/p&gt;
&lt;p&gt;After closing this dialog, only the Client ID appears on the main credentials page. To access your secret subsequently, select your OAUTH credentials by name.&lt;/p&gt;
&lt;h3 id=&#34;download-your-credentials-as-a-json-file&#34;&gt;Download Your Credentials as a JSON File&lt;/h3&gt;
&lt;p&gt;On the credentials page, a download icon appears to the right of your OAUTH credentials. Selecting this downloads credentials in JSON format.&lt;/p&gt;
&lt;p&gt;The downloaded file carries an extensive filename. For practical purposes, rename it to something manageable like &amp;ldquo;secrets.json&amp;rdquo;. Move this file from your downloads folder to an accessible location, such as your home directory.&lt;/p&gt;
&lt;h2 id=&#34;get-the-api-library-on-your-computer&#34;&gt;Get the API Library on Your Computer&lt;/h2&gt;
&lt;p&gt;Now comes the exciting part — retrieving the Google Ads API locally and executing your inaugural call.&lt;/p&gt;
&lt;p&gt;Start by entering a Python virtual environment.&lt;/p&gt;
&lt;p&gt;Within your virtual environment, install setuptools, a prerequisite for the API library.&lt;/p&gt;
&lt;p&gt;Install the library using pip by typing this command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;pip install google-ads
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The library includes extensive example code deserving easy access. Cloning the API library Git repository directly into your home directory proves helpful:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;git clone git@github.com:googleads/google-ads-python.git
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Navigate into the library and execute the setup test to verify proper installation:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;python setup.py test
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;theres-one-last-credential-we-need-to-get&#34;&gt;There&amp;rsquo;s One Last Credential We Need to Get&lt;/h2&gt;
&lt;p&gt;Yes, there&amp;rsquo;s another credential required. Consider this comprehensive authentication process as a competitive barrier. The final credential — a refresh token — allows refreshing your credentials upon expiration.&lt;/p&gt;
&lt;p&gt;Navigate to the google-ads-python directory created during repository cloning, then proceed to the examples/authentication folder:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cd examples/authentication
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Three files reside in this directory. The target file is authenticate_in_standalone_application.py. Execute it, specifying your previously downloaded JSON file location. Type this command (substituting /path/to/secrets.json with your actual file path and name):&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;./authenticate_in_standalone_application.py --client_secrets_path=/path/to/secrets.json
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This script generates a URL.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Launch a private or incognito browser session.&lt;/strong&gt; This URL carries sensitive information — you shouldn&amp;rsquo;t preserve it in your browser history. Transfer the URL into your private browser session.&lt;/p&gt;
&lt;p&gt;Select &lt;strong&gt;allow&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;An authorization code becomes visible.&lt;/p&gt;
&lt;p&gt;Transfer the verification code to your command line session running authenticate_in_standalone_application.py and press enter:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;After approving the token enter the authorization code here: ****
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Upon successful entry:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;After approving the token enter the authorization code here: ****
Your refresh token is: ****
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Document this refresh token in an accessible location.&lt;/p&gt;
&lt;h2 id=&#34;rounding-up-all-your-credentials-and-getting-them-configured&#34;&gt;Rounding Up All Your Credentials and Getting Them Configured&lt;/h2&gt;
&lt;p&gt;You should now possess a collection of credentials stored somewhere accessible. Time to implement them.&lt;/p&gt;
&lt;p&gt;By default, the Google Ads API searches for credentials in a YAML file within the home directory labeled google-ads.yaml. This file resides within your cloned google-ads-python directory from GitHub. Your tasks involve:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Duplicate the YAML file&lt;/li&gt;
&lt;li&gt;Relocate it to your home directory&lt;/li&gt;
&lt;li&gt;Populate it with all credentials you&amp;rsquo;ve accumulated&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;After transferring the file to your home directory, modify it with your appropriate information and save it.&lt;/p&gt;
&lt;h2 id=&#34;make-your-first-api-call&#34;&gt;Make Your First API Call!&lt;/h2&gt;
&lt;p&gt;Finally, the moment arrives. Execute an API call retrieving the name of your test account campaign.&lt;/p&gt;
&lt;p&gt;First, navigate to the relevant example script:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;cd google-ads-python/examples/basic_operations
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Execute get_campaigns.py, providing your test account number as an argument:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;python get_campaigns.py -c1234567890
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Observe how the account ID transfers without spacing or dashes. Assuming correct configuration, you&amp;rsquo;ll receive output resembling:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Campaign with ID xxxxxxxxxxx and name &amp;#34;Campaign-Name-1&amp;#34; was found.
&lt;/code&gt;&lt;/pre&gt;</content>
    </item>
    
    <item>
      <title>Scraping TripAdvisor reviews using Python</title>
      <link>/posts/scraping-tripadvisor-reviews-using-python/</link>
      <pubDate>Mon, 19 Feb 2024 00:00:00 +0000</pubDate>
      <author>cahoover@gmail.com (Christopher Hoover)</author>
      <guid>/posts/scraping-tripadvisor-reviews-using-python/</guid>
      <description>&lt;p&gt;We&amp;rsquo;re going to use scrape review data from Tripadvisor, which would be helpful if you wanted to do a NLP analysis of reviews as a way to keep your finger on the pulse of customer satisfaction.&lt;/p&gt;
&lt;p&gt;Selenium is a tool that lets you control your desktop browser programmatically. Tripadvisor requires a &amp;ldquo;read more&amp;rdquo; button to be clicked to reveal the entire review, and Selenium is a good tool to easily get this done.&lt;/p&gt;</description>
      <content>&lt;p&gt;We&amp;rsquo;re going to use scrape review data from Tripadvisor, which would be helpful if you wanted to do a NLP analysis of reviews as a way to keep your finger on the pulse of customer satisfaction.&lt;/p&gt;
&lt;p&gt;Selenium is a tool that lets you control your desktop browser programmatically. Tripadvisor requires a &amp;ldquo;read more&amp;rdquo; button to be clicked to reveal the entire review, and Selenium is a good tool to easily get this done.&lt;/p&gt;
&lt;h2 id=&#34;install-selenium&#34;&gt;Install Selenium&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ll assume you&amp;rsquo;re using Anaconda for environment management. First, activate an environment with&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;conda activate [environment]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Install Selenium with:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;conda install -c conda-forge selenium
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;import-packages&#34;&gt;Import packages&lt;/h2&gt;
&lt;p&gt;The first thing we&amp;rsquo;ll do is import the required packages. There aren&amp;rsquo;t many:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; csv &lt;span style=&#34;color:#75715e&#34;&gt;#This package lets us save data to a csv file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;from&lt;/span&gt; selenium &lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; webdriver &lt;span style=&#34;color:#75715e&#34;&gt;#The Selenium package we&amp;#39;ll need&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; time &lt;span style=&#34;color:#75715e&#34;&gt;#This package lets us pause execution for a bit&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;define-variables&#34;&gt;Define variables&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ll need to set up some variables.&lt;/p&gt;
&lt;p&gt;First, define a path and file to store data. Here I&amp;rsquo;m just putting it on my Mac&amp;rsquo;s desktop&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;path_to_file &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/Users/chris/Desktop/HotelReviews.csv&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, define the number of review pages to scrape. There might be hundreds of pages of reviews, depending on the property. For this demonstration we&amp;rsquo;ll keep it easy and just grab three pages.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pages_to_scrape &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, define the Tripadvisor URL. We&amp;rsquo;ll use the Hilton Waikiki resort page, because it&amp;rsquo;s a super nice hotel!&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;url &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;https://www.tripadvisor.com/Hotel_Review-g60982-d209422-Reviews-Hilton_Waikiki_Beach-Honolulu_Oahu_Hawaii.html&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;get-selenium-on-the-right-page-and-set-up-the-csv&#34;&gt;Get Selenium on the right page and set up the CSV&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s launch Selenium and have it point the browser to the URL we&amp;rsquo;re using. This example uses the Safari browser, but you can remote control Chrome (or any other browser) if you prefer.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# import the webdriver&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;driver &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; webdriver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;Safari()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;get(url)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We&amp;rsquo;ll also get a CSV set up to contain the data we retrieve&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# open the file to save the review&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;csvFile &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; open(path_to_file, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;a&amp;#39;&lt;/span&gt;, encoding&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;utf-8&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;csvWriter &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; csv&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;writer(csvFile)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;programmatically-grab-the-reviews-one-after-the-other&#34;&gt;Programmatically grab the reviews, one after the other&lt;/h2&gt;
&lt;p&gt;Now it&amp;rsquo;s time to tell Selenium to grab the reviews. Because Tripadvisor reviews are truncated, we&amp;rsquo;ll be sure and click the &amp;ldquo;read more&amp;rdquo; button for all reviews first.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# change the value inside the range to save the number of reviews we&amp;#39;re going to grab&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;, pages_to_scrape):
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# give the DOM time to load&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    time&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;sleep(&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# Click the &amp;#34;expand review&amp;#34; link to reveal the entire review.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_element_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.//div[contains(@data-test-target, &amp;#39;expand-review&amp;#39;)]&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;click()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# Now we&amp;#39;ll ask Selenium to look for elements in the page and save them to a variable. First lets define a  container that will hold all the reviews on the page. In a moment we&amp;#39;ll parse these and save them:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    container &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_elements_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;//div[@data-reviewid]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# Next we&amp;#39;ll grab the date of the review:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    dates &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_elements_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.//div[@class=&amp;#39;_2fxQ4TOx&amp;#39;]&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;   &lt;span style=&#34;color:#75715e&#34;&gt;# Now we&amp;#39;ll look at the reviews in the container and parse them out&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; j &lt;span style=&#34;color:#f92672&#34;&gt;in&lt;/span&gt; range(len(container)): &lt;span style=&#34;color:#75715e&#34;&gt;# A loop defined by the number of reviews&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;# Grab the rating&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        rating &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; container[j]&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_element_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.//span[contains(@class, &amp;#39;ui_bubble_rating bubble_&amp;#39;)]&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;get_attribute(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;class&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;split(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;_&amp;#34;&lt;/span&gt;)[&lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;# Grab the title&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        title &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; container[j]&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_element_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.//div[contains(@data-test-target, &amp;#39;review-title&amp;#39;)]&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;text
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;#Grab the review&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        review &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; container[j]&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_element_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.//q[@class=&amp;#39;IRsGHoPm&amp;#39;]&amp;#34;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;text&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;replace(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\n&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;  &amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;#Grab the data&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        date &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;join(dates[j]&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;text&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;split(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34; &amp;#34;&lt;/span&gt;)[&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;:])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#75715e&#34;&gt;#Save that data in the csv and then continue to process the next review&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        csvWriter&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;writerow([date, rating, title, review])
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;# When all the reviews in the container have been processed, change the page and repeat&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;find_element_by_xpath(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;.//a[@class=&amp;#34;ui_button nav next primary &amp;#34;]&amp;#39;&lt;/span&gt;)&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;click()
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;# When all pages have been processed, quit the driver&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;driver&lt;span style=&#34;color:#f92672&#34;&gt;.&lt;/span&gt;quit()
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;conclusion&#34;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s it! A very simple program. You&amp;rsquo;ll now have a csv that contains all the reviews you retrieved.&lt;/p&gt;
</content>
    </item>
    
  </channel>
</rss>
