text stringlengths 14 100k | source stringclasses 1
value | repo stringclasses 810
values | language stringclasses 13
values |
|---|---|---|---|
<|fim_suffix|>ng Message
{
get
{
if (msg == null)
{
if(!string.IsNullOrWhiteSpace(Text))
{
msg = Error + Environment.NewLine + Text;
}
else
... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>: InternalsVisibleTo("UniTask.Addressables")]
[assembly: InternalsVisibleTo("UniTask.DOTween")]
[assembly: InternalsVisibleTo("UniTask.TextMeshPro")]<|fim_prefix|>using System.Runtime.CompilerSer<|fim_middle|>vices;
[assembly: InternalsVisibleTo("UniTask.Linq")]
[assembly<|endoftext|> | fim | Cysharp/UniTask | csharp |
<|fim_suffix|> // "Assets/Scenes/SandboxMain.unity",
//};
//try
//{
// Debug.Log("Build Begin");
// BuildPipeline.BuildPlayer(scenes, Application.dataPath + "../target", BuildTarget.StandaloneWindows, BuildOptions.CompressWithLz4);
// Debug.Log("Build Af... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>ss ExceptionExamples : MonoBehaviour
{
public bool apply = false;
private async UniTaskVoid Update()
{
if (apply)
{
apply = false;
await LaunchTasksAndDetectWhenAnyDone(5);
}
}
private async UniTask LaunchTasksAndDetectWhenAnyDone(int n... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>n);
// linkToken.CancelAfterSlim(timeout);
// try
// {
// // 完了待ちや終了処理はUniTaskの拡張自体に丸投げ
// await req.SendWebRequest().ToUniTask(progress: progress, cancellationToken: linkToken.Token);
// }
// ... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|> await d.DisposeAsync();
}
UnityEngine.Debug.Log("In ThreadPool?" + Thread.CurrentThread.ManagedThreadId);
UnityEngine.Debug.Log("SyncContext is null2" + (SynchronizationContext.Current == null));
}
private void Update()
{
// UnityEngine.Debug.Log("Update:" ... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>WaitWhile(IsContinued, cancellationToken: m_CancelTokenSource.Token, cancelImmediately: true);
Debug.Log("Task Finished");
}
catch (OperationCanceledException)
{
Debug.LogWarning("Task Canceled");
}
finally
{
CancelAndDisp... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using System.Collections;
using System.Coll<|fim_suffix|> // // var aaa = await foo;
// // Debug.Log(aaa);
// await UniTask.Yield();
// //File.WriteAllText(filePath, req.downloadHandler.text ?? string.Empty);
//}
}
<|fim_middle|>ections.Generic;... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>mple_texture.png");
var task = UnityWebRequest.Get($"file://{filePath}").SendWebRequest().ToUniTask(cancellationToken: cts.Token, cancelImmediately: true);
task.Status.Should().Be(UniTaskStatus.Canceled);
}
#endif
}
}
#endif
<|fim_prefix|>using System.Colle... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#if !(UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
u... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>;
}
if (yield)
{
await UniTask.Yield();
}
if (cacheDict.TryGetValue(cache, out var v))
{
return v;
}
cacheDict.Add(cache, value);
return value;
}
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
u... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable CS0618
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>default(UniTask);
// await UniTask.DelayFrame(3);
// GC.Collect();
// GC.WaitForPendingFinalizers();
// GC.Collect();
// await UniTask.DelayFrame(1);
// calledEx.Should().BeTrue();
// UniTaskScheduler.UnobservedTaskException... | fim | Cysharp/UniTask | csharp |
//#if !(UNITY_4_5 || UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
//#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
//using UnityEngine;
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;... | fim | Cysharp/UniTask | csharp |
//#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
//#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
//using UnityEngine;
//using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>
// await UniTask.WhenAll(t01, t02, t03, t04, t05, t06, t07);
//});
//[UnityTest]
//public IEnumerator WhenAllT15_Generics1() => UniTask.ToCoroutine(async () =>
//{
// var t01 = Tes<MyGenerics<int>>();
// var t02 = Tes<MyGenerics<int>>();
... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>lationTokenSource();
var complete = new UniTaskCompletionSource();
cts.Token.RegisterWithoutCaptureExecutionContext(() =>
{
complete.TrySetResult();
});
cts.CancelAfterSlim(TimeSpan.FromSeconds(1));
var sw = Stopwatc... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|> var afterOne = UnityEngine.Time.frameCount; // 5
await delay;
var afterTwo = UnityEngine.Time.frameCount; // 5
(afterOne - before).Should().Be(5);
afterOne.Should().Be(afterTwo);
});
}
}
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Flu... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>>
{
var main = Thread.CurrentThread.ManagedThreadId;
var v = await UniTask.Run(() => 3, true);
v.Should().Be(3);
main.Should().Be(Thread.CurrentThread.ManagedThreadId);
});
//[UnityTest]
//public IEnumerator RunThreadExceptio... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>us<|fim_suffix|>ic Bool(bool value)
{
actual = value;
}
public void Be(bool expected)
{
Assert.AreEqual(expected, actual);
}
public void NotBe(bool expected)
{
Assert.AreN... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>ch (Exception ex)
{
ex.Should().BeAssignableTo<OperationCanceledException>();
}
});
}
}
#endif<|fim_prefix|>#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warn<|fim_middle|>ing disable CS1591 // Missing XML co... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable RS2008
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using<|fim_suffix|><DiagnosticDescriptor> SupportedDiagnostics { get { return ImmutableArray.Create(Rule); } }
public override void Initialize(Analysis... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#if !NETSTANDARD2_0
#pragma warning disable 0649
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Threading.Tasks.Sources;
namespace Cysharp.Threading.Tasks
{
public static class AsyncEnumerableExtensions
{
public static... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|> throw new NotImplementedException();
// }
// public void OnCompleted(Action<object> continuation, object state, short token)
// {
// throw new NotImplementedException();
// }
// public UniTaskStatus UnsafeGetStatus()
// ... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>;
}
}
/// <summary>Run action on the threadPool and return to current SynchronizationContext if configureAwait = true.</summary>
public static async UniTask Run(Action<object> action, object state, bool configureAwait = true)
{
if (configureAwait)
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks.Internal;
using System;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Cysharp.Threading.Tasks
{
public partial struct UniTask
{
public static UniTask.YieldAwaitable Yield()
{
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable CS1998
using Cysharp.Threading.Tasks;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Threading;
using System.<|fim_suffix|> Error)
// await FooAsync(10);
}
static async UniTask FooAsync(int x, Ca... | fim | Cysharp/UniTask | csharp |
using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
public class... | fim | Cysharp/UniTask | csharp |
using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
public class... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>cNow;
await cts.Token.WaitUntilCanceled();
var elapsed = DateTime.UtcNow - now;
elapsed.Should().BeGreaterThan(TimeSpan.FromSeconds(1));
}
[Fact]
public void AlreadyCanceled()
{
var cts = new CancellationTokenSource();
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class Aggregate
{
... | fim | Cysharp/UniTask | csharp |
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class AllAny
... | fim | Cysharp/UniTask | csharp |
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class Concat
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public ... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable CS1998
#pragma warning disable CS0162
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class Factory
{
[Theory]
[InlineData(0, 10)]
[InlineData(0, 0)]
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public... | fim | Cysharp/UniTask | csharp |
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class FirstLas... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace NetCor... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|> b = UniTaskAsyncEnumerable.Create<string>(async (writer, _) =>
{
throw new UniTaskTestException();
});
var enumerator = a.Merge(b).GetAsyncEnumerator();
(await enumerator.MoveNextAsync()).Should().Be(true);
enumerator.Current.Sh... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>oArray();
xs.Should().Equal(ys);
}
{
var xs = await UniTaskAsyncEnumerable.Range(1, collection).TakeWhileAwait((x, i) => UniTask.Run(() => x < (skipCount - i))).ToArrayAsync();
var ys = Enumerable.Range(1, collection).TakeWhile((x, i... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Concurrency;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>ar rp = new AsyncReactiveProperty<int>(1);
var multicast = rp.Publish();
var a = multicast.ToArrayAsync();
var b = multicast.Take(2).ToArrayAsync();
var disp = multicast.Connect();
rp.Value = 2;
(await b).Should().Equal(1, 2);
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
us<|fim_suffix|> var l = new List<int>();
await rp.Take(10).Queue().ForEachAsync(x =>
{
rp.Value += 10;
l.Add(x);
});
l.Should().Equal(100, 110, 120, 130, ... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>.DistinctUntilChanged(x => x).ToArrayAsync()).Should().Equal(ys);
(await array.ToUniTaskAsyncEnumerable().DistinctUntilChangedAwait(x => UniTask.Run(() => x)).ToArrayAsync()).Should().Equal(ys);
(await array.ToUniTaskAsyncEnumerable().DistinctUntilChangedAwaitWithCancellati... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>x.LastName)).ToArrayAsync();
var g2 = await array.ToUniTaskAsyncEnumerable().OrderByDescendingAwait(x => RandomRun(x.Age)).ThenByDescendingAwait(x => RandomRun(x.FirstName)).ThenByAwait(x => RandomRun(x.LastName)).ToArrayAsync();
var h2 = await array.ToUniTaskAsyncE... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests.Linq
{
public class TakeInfinityTest
{
[... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
using System;
using System.Collections.Generic;
using System.Runtime.ExceptionServices;
using System.Threading;
namespace NetCoreTests.Linq
{
public class UniTaskTestException : Exception
{
public static IUniTaskAsyncEnum... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable CS1998
using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Channels;
using Cysharp.Threading.Tasks.Linq;
using System.Threading.Tasks;
using Xu... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>#pragma warning disable CS1998
using System;
using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
public class TaskExtensionsTest
{
[Fact]
public async Task PropagateException()
{
<|fim_suffix|>lidOperationException();... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>3);
ev.Add(two);
ev.Add(one); // add second
ev.Add(three);
ev.SetResult(10);
ev.SetResult(20);
ev.SetResult(30);
one.NextCalled.Should().Equal(10, 20, 30);
two.NextCalled.Shou... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>ption(new UniTaskTestException()).Should().BeFalse();
}
}
}<|fim_prefix|>using System.Threading.Tasks;
using Cysharp.Threading.Tasks;
using FluentAssertions;
using NetCoreTests.Linq;
using Xunit;
namespace NetCoreTests
{
public class AutoResetUniTaskCompletionSourceTest
{
[Fac... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>e(1);
}
async UniTask<int> Delay(int id, int sleep)
{
await Task.Delay(sleep);
return id;
}
async UniTask<int> Delay2(int id, int sleep)
{
await Task.Delay(sleep);
if (id == 3) throw new Exception("ERROR");
... | fim | Cysharp/UniTask | csharp |
<|fim_prefix|>using Cysharp.Threading.Tasks;
using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace NetCoreTests
{
public class WithCancellationTest
{
[Fact]
public async Task Stand... | fim | Cysharp/UniTask | csharp |
<|fim_suffix|>ate(all_quotes, 1):
print(f"{i:>3}. {quote}")
<|fim_prefix|>"""
Example 1: Python - FetcherSession (persistent HTTP session with Chrome TLS fingerprint)
Scrapes all 10 pages of quotes.toscrape.com using a single HTTP session.
No browser launched - fast and lightweight.
Best for: static or semi-stati... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Example <|fim_suffix|>e.com using a persistent browser session.
The browser window stays open across all page requests for efficiency.
Best for: JavaScript-heavy pages, SPAs, sites with dynamic content loading.
Set headless=True to run the browser hidden.
Set disable_resources=True to skip loading i... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Example 3: Python - StealthySession (Patchright stealth browser, visible)
Scrapes all 10 pages of quotes.toscrape.com using a persistent stealth browser session.
Bypasses anti-bot protections automatically (Cloudflare Turnstile, fingerprinting, etc.).
Best for: well-protected sites, Cloudflare-gated... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>print(f"{'=' * 50}\n")
for i, item in enumerate(result.items, 1):
print(f"{i:>3}. [{item['author']}] {item['text']}")
if item["tags"]:
print(f" Tags: {', '.join(item['tags'])}")
# Export to JSON
result.items.to_json("quotes.json", indent=True)
print("\nE... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ke average)
times = timeit.repeat(
lambda: func(*args, **kwargs),
number=1,
repeat=100,
globals=globals(),
timer=time.process_time,
)
min_time = round(mean(times) * 1000, 2) # Convert to milliseconds
print(f"avera... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> ".pytest_cache",
]
# Clean directories
for pattern in cleanup_patterns:
for path in base_dir.glob(pattern):
try:
if path.is_dir():
shutil.rmtree(path)
else:
path.unlink()
print(f"Rem... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>and autocomplete."""
return sorted(__all__ + ["fetchers", "parser", "cli", "core", "__author__", "__version__", "__copyright__"])
<|fim_prefix|>__author__ = "Karim Shoair (karim.shoair@pm.me)"
__version__ = "0.4.9"
__copyright_<|fim_middle|>_ = "Copyright (c) 2024 Karim Shoair"
from typing import Any... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from pathlib import Path
from subprocess import check_output
from sys import executable as python_executable
from scrapling import __version__
from scrapling.core.utils import log
from scrapling.engines.toolbelt.custom import Response
from scrapling.core.utils._shell import _CookieParser, _ParseHeaders
f... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>_path": Optional[str],
"dns_over_https": bool,
"allow_webgl": bool,
"hide_canvas": bool,
"block_webrtc": bool,
"solve_cloudflare": bool,
}
# Mapping of function names to their parameter definitions
Signatures_map = {
"get": _REQUESTS_PARAMS,
"post": {**_REQUESTS_PARAMS, "data"... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>es = Literal["attached", "detached", "hidden", "visible"]
PageLoadStates = Literal["commit", "domcontentloaded", "load", "networkidle"]
extraction_types = Literal["text", "html", "markdown"]
StrOrBytes = Union[str, bytes]
FollowRedirects = Union[bool, Literal["safe", "all", "obeycode", "firstonly"]]
# C... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>return the text content of the page.
:param css_selector: CSS selector to extract the content from the page. If main_content_only is True, then it will be executed on the main content of the page. Defaults to None.
:param main_content_only: Whether to extract only the main content of the p... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>Handler(Mapping[str, _TextHandlerType]):
"""A read-only mapping to use instead of the standard dictionary for the speed boost, but at the same time I use it to add more functionalities.
If the standard dictionary is needed, convert this class to a dictionary with the `dict` function
"""
_... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from scrapling.core._types import Any, Dict
class SelectorsGeneration:
"""
Functions for generating selectors
Trying to generate selectors like Firefox or maybe cleaner ones!? Ehm
Inspiration: https://searchfox.org/mozilla-central/source/devtools/shared/inspector/css-logic.js#591
"""... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> """Strip hidden content that could be used for prompt injection.
Removes CSS-hidden elements, aria-hidden elements, <template> tags,
HTML comments, and zero-width Unicode characters.
"""
clean_root = deepcopy(page._root)
for element in cast(list, _HIDDEN_XPATH(cl... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from hashlib import sha256
from threading import RLock
from functools import lru_cache
from abc import ABC, abstractmethod
from sqlite3 import connect as db_connect
from orjson import dumps, loads
from lxml.html import HtmlElement
from scrapling.core.utils import _StorageTools, log
from scrapling.core._... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ues/14757
xpath = super().xpath_element(selector) # type: ignore[safe-super]
return XPathExpr.from_xpath(xpath)
def xpath_pseudo_element(self, xpath: OriginalXPathExpr, pseudo_element: PseudoElement) -> OriginalXPathExpr:
"""
Dispatch method that transforms XPath to s... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from ._utils import (
lo<|fim_suffix|> html_forbidden,
)
<|fim_middle|>g,
set_logger,
reset_logger,
__CONSECUTIVE_SPACES_REGEX__,
flatten,
_is_iterable,
_StorageTools,
clean_spaces,
<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from http import cookies as Cookie
from scrapling.core._types import (
List,
Dict,
Tuple,
)
def _CookieParser(cookie_string):
# Errors will<|fim_suffix|>eaders(header_lines: List[str], parse_cookies: bool = True) -> Tuple[Dict[str, str], Dict[str, str]]:
"""Parses headers into sepa... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> "parent_attribs": dict(parent.attrib),
"parent_text": parent.text.strip() if parent.text else None,
}
)
siblings = [child.tag for child in parent.iterchildren() if child != element]
if siblings:
result.updat... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>te_stealth_options(self) -> None:
config = cast(StealthConfig, self._config)
flags: Tuple[str, ...] = tuple()
if not config.cdp_url:
flags = tuple(DEFAULT_ARGS) + tuple(STEALTH_ARGS)
if config.block_webrtc:
flags += (
"--... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ome").get("User-Agent")
<|fim_prefix|>from scrapling.en<|fim_middle|>gines.toolbelt.fingerprints import generate_headers
__default_useragent__ = generate_headers(browser_mode=True).get("User-Agent")
__default_chrome_useragent__ = generate_headers(browser_mode="chr<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>_info,
final_response,
xhr_pattern=self._config.capture_xhr,
xhr_container=xhr_captured,
),
)
if params.page_setup:
try:
params.page_setu... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from threading import RLock
from dataclasses import dataclass
from playwright.sync_api._generated import Page as Syn<|fim_suffix|>= url
def mark_error(self):
"""Mark the page as having an error"""
self.state = "error"
def __repr__(self):
return f'Page(URL="{self.url!r}",... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from random import randint
from re import compile as re_compile
from time import sleep as time_sleep
from asyncio import sleep as asyncio_sleep
from playwright.sync_api import Locator, Page
from playwright.async_api import Page as async_Page, Locator as AsyncLocator
from patchright.sync_api import sync_p... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from io import BytesIO
from curl_cffi.requests import (
ProxySpec,
CookieTypes,
BrowserTypeLiteral,
)
from scrapling.core._types import (
Dict,
List,
Set,
Tuple,
Mapping,
Optional,
Callable,
Sequence,
TypedDict,
TypeAlias,
SetCookieParam,
Selec... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ra_headers: Optional[Dict[str, str]] = None
timeout: Seconds = 30000
init_script: Optional[str] = None
user_data_dir: str = ""
selector_config: Optional[Dict] = {}
additional_args: Optional[Dict] = {}
locale: str | None = None
real_chrome: bool = False
cdp_url: Optional[str... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>-disable-backgrounding-occluded-windows",
"--disable-layer-tree-host-memory-pressure",
"--autoplay-policy=user-gesture-required",
"--disable-offer-store-unmasked-wallet-cards",
"--disable-blink-features=AutomationControlled",
"--disable-component-extensions-with-background-pages",
... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from abc import ABC
from random import choice
from time import sleep as time_sleep
from asyncio import sleep as asyncio_sleep
from curl_cffi.curl import CurlError
from curl_cffi import CurlHttpVersion
from curl_cffi.requests import (
BrowserTypeLiteral,
Session as CurlSession,
AsyncSession as... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ation
__all__ = ["ProxyRotator", "is_proxy_error", "cyclic_rotation"]
<|fim_prefix|>from .proxy_rotation import Pr<|fim_middle|>oxyRotator, is_proxy_error, cyclic_rot<|endoftext|> | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>"""
Built-in ad/tracker domain list for use with block_ads=True.
Source: Peter Lowe's ad and tracking server list https://pgl.yoyo.org/adservers/
Used config: https://pgl.yoyo.org/adservers/serverlist.php?hostformat=plain&showintro=0&startyear=2000&mimetype=plaintext
"""
AD_DOMAINS: frozenset = frozense... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from functools import lru_cache
from re import compile as re_compile
from curl_cffi.requests import Response as CurlResponse
from playwright._impl._errors import Error as PlaywrightError
from playwright.sync_api import Page as SyncPage, Response as SyncResponse
from playwright.async_api import Page as As... | fim | D4Vinci/Scrapling | python |
"""
Functions related to custom types or type checking
"""
from functools import lru_cache
from scrapling.core.utils import log
from scrapling.core._types import (
Any,
Dict,
cast,
List,
Tuple,
Union,
Optional,
Callable,
Sequence,
TYPE_CHECKING,
AsyncGenerator,
)
from scrap... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> ]
)
return HeaderGenerator(browser=browsers, os=os_name, device="desktop").generate()
__default_useragent__ = generate_headers(browser_mode=False).get("User-Agent")
<|fim_prefix|>"""
Functions related to gen<|fim_middle|>erating headers and fingerprints generally
"""
from functools import ... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>sult_dict
except ValidationError as e:
raise TypeError(f"Invalid proxy dictionary: {e}")
raise TypeError(f"Invalid proxy string: {proxy_string}")
<|fim_prefix|>"""
Functions related to files and URLs
"""
from urllib.parse import urlparse
from playwright.async_api import Route as... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> -> str:
return f"ProxyRotator(proxies={len(self._proxies)})"
<|fim_prefix|>from threading import Lock
from scrapling.core._types import Callable, Dict, List, Tuple, ProxyType
RotationStrategy = Callable[[List[ProxyType], int], Tuple[ProxyType, int]]
_PROXY_ERROR_INDICATORS = {
"net::err_pr... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>lthySession",
]
def __getattr__(name: str) -> Any:
if name in _LAZY_IMPORTS:
module_path, class_name = _LAZY_IMPORTS[name]
module = __import__(module_path, fromlist=[class_name])
return getattr(module, class_name)
else:
raise AttributeError(f"module {__name__!r} h... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>ons below.
:param url: Target url.
:param headless: Run the browser in headless/hidden (default), or headful/visible mode.
:param disable_resources: Drop requests for unnecessary resources for a speed boost.
:param blocked_domains: A set of domain names to block requests t... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>stance__.put(url, **_merge_selector_config(cls, kwargs))
@classmethod
def delete(cls, url: str, **kwargs: Unpack[DataRequestParams]) -> Response:
return __FetcherClientInstance__.delete(url, **_merge_selector_config(cls, kwargs))
class AsyncFetcher(BaseFetcher):
"""A basic `Fetcher`... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from scrapling.core._types import Unpack
from scrapling.engines._browsers._types import StealthSession
from scrapling.engines.toolbelt.custom import BaseFetcher, Response
from scrapling.engines._browsers._stealth import StealthySession, AsyncStealthySession
class StealthyFetcher(BaseFetcher):
"""A `... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|> fulfill passed regex patterns
for pattern in patterns:
results = results.filter(lambda e: e.text.re(pattern, check_match=True))
# From the results, get the ones that fulfill passed functions
for function in functions:
... | fim | D4Vinci/Scrapling | python |
<|fim_suffix|>"CrawlerEngine",
"CrawlResult",
"SessionManager",
"Scheduler",
"Response",
"LinkExtractor",
"CrawlSpider",
"CrawlRule",
"SitemapSpider",
]
<|fim_prefix|>from .request import Request
from .result import CrawlResult
from .scheduler import Scheduler
from .engine import Crawler... | fim | D4Vinci/Scrapling | python |
<|fim_prefix|>from base64 import b64encode, b64decode
from pathlib import Path
import orjson
import anyio
from anyio import Path as AsyncPath
from scrapling.core.utils import log
from scrapling.core._types import Dict, Optional, Any
from scrapling.engines.toolbelt.custom import Response
class Res<|fim_suffix|>] = o... | fim | D4Vinci/Scrapling | python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.