Skip to content

Commit

Permalink
fix cloudflare returning 403 forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
dsychin committed Feb 17, 2023
1 parent 25c02d7 commit fdcfdd6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 7.0.200
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"omnisharp.useModernNet": true
}
1 change: 1 addition & 0 deletions RedditBruneiNewsBot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private static async Task<StringBuilder> GetBorneoBulletinArticle(Uri uri)
var handler = new HttpClientHandler { Proxy = proxy };

using var httpClient = new HttpClient(handler, true);
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36");

var response = await httpClient.GetAsync(uri.ToString());
response.EnsureSuccessStatusCode();
Expand Down
4 changes: 2 additions & 2 deletions RedditBruneiNewsBot/RedditBruneiNewsBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.28" />
<PackageReference Include="HtmlAgilityPack.CssSelectors.NetCore" Version="1.2.1" />
<PackageReference Include="HttpToSocks5Proxy" Version="1.4.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Reddit" Version="1.5.2" />
</ItemGroup>

Expand Down

0 comments on commit fdcfdd6

Please sign in to comment.